How to upgrade yolk to yolk3k in a virtual env? - python-3.x

I have just started using virtualenv from this tutorial, where it uses yolk to list the packages installed in the virtualenv, but yolk by default is for Python 2, so I decided to upgrade with an extension for Python 3, my current version, with the following command:
pip3 install --upgrade yolk3k
It works when I am not in the virtualenv that I called virt0, but if I am on it, it gives me the error it was giving me before upgrading it to the Python 3 version.
print " %s %s (%s)" % (project_name, dist.version,
^
SyntaxError: invalid syntax
When I tried to install yolk in the virt0, the output was the following:
Searching for yolk
Best match: yolk 0.4.3
Processing yolk-0.4.3-py3.4.egg
yolk 0.4.3 is already the active version in easy-install.pth
Installing yolk script to /Users/user/Desktop/virt_env/virt0/bin
Using /Users/user/Desktop/virt_env/virt0/lib/python3.4/site-packages/yolk-0.4.3-py3.4.egg
Processing dependencies for yolk
Finished processing dependencies for yolk
In /Users/user/Desktop/virt_env/virt0/bin, I have this:
activate pip3
activate.csh pip3.4
activate.fish python
activate_this.py python3
easy_install python3.4
easy_install-3.4 yolk
pip
which confirms that yolk was installed, but how can I update it also to yolk3k in virt0?
If I try to install yolk3k with the following command:
pip3 install --upgrade yolk3k
inside /Users/user/Desktop/virt_env/virt0/bin, it outputs:
Requirement already up-to-date: yolk3k in /Users/user/Desktop/virt_env/virt0/lib/python3.4/site-packages
but it still gives me the error I cited above.

Delete the virtualenv, recreate it with Python 3 as the interpreter and install all dependencies for Python 3 (such as yolk3k). The problem seems to come from the fact that you're going from a 2.x to a 3.x environment even though the virtualenv originally wasn't.
That's not the intended way of using a virtualenv - a virtualenv should be tied to one particular Python version (e.g., 2.7 or 3.4) with all dependencies installed for that version. So you should throw away the virtualenv and rebuild it entirely using 3.x dependencies. That should resolve any conflicting language issues.

Related

import distutils.command.bdist_wininst as orig

Everything went well while I was trying to create a ros 2 package in Ubuntu 22.04 by following the ros2 documentation, however when I got to the colcon build step, it failed for python packages even though it works for cMake packages.
colcon build --packages-select mypkgpython
...
import distutils.command.bdist_wininst as orig
ModuleNotFoundError: No module named 'distutils.command.bdist_wininst'
knowing that my python version is:
python3 --version
Python 3.10.6
i have tried:
sudo apt-get install python3-distutils:
python3-distutils is already the newest version (3.10.6-1~22.04).
sudo apt-get install python3-apt:
python3-apt is already the newest version (2.4.0).
sudo apt install python3-colcon-common-extensions
python3-colcon-common-extensions is already the newest version(0.3.0-1)
how can i solve this problem?
i expected when i build my python package using
colcon build package
it will be successfully build, so i could work with
The bdist_wininst command was deprecated in Python 3.8 and you are using python 3.10
Its no more found in python3-distutils package .
use
bdist_wheel (wheel packages) instead
or
if you want to run your code as it is downgrade your python to < 3.8
The bdist_wininst format was deprecated in Python 3.8, and the documentation for this format has been removed in Python 3.9. The recommended way to distribute Python packages now is the Wheel format.
you can overcome this error by JUST updating the setuptools
pip install --upgrade setuptools
Note that: Setuptools version 58.2.0 is the last version that works with ROS 2 python packages without any warnings because it is the last version that supports the old installation method, "python setup.py install." This method has been deprecated and replaced by newer, standards-based tools, such as pip and ament.
pip install setuptools==58.2.0

Python3: No module named dateutil

I am unable to get dateutil installed in my Python code.
from dateutil import tz
ImportError: No module named dateutil
I had date-util installed (Python version is 3.7.3)
> pip3 install python-dateutil
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: python-dateutil in /usr/lib/python3/dist-packages (2.7.3)
I cannot uninstall them (to reinstall). I get the following error
> sudo pip3 uninstall python-dateutil
Not uninstalling python-dateutil at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'python-dateutil'. No files were found to uninstall.
Then, I used the following command to uninstall:
> sudo apt-get remove python3-dateutil #This worked
> pip3 install python-dateutil
This works, but asks me to install cycler, kiwisolver, pyparsing, which I install using pip3. But I still cant get the python code working - has the same error (ImportError: No module named dateutil)
Any suggestions on what's going on?
I found a solution - The python code is being called from a bash script. It worked fine until recently. Recently I installed some other packages that installed python 2.x. So, the python scripts were using Python 2.x rather than 3.x. I had symbolic links to python 3.x, but that didn't help.
Now, I am explicitly use python3 mycode.py to overcome this issue.
I highly recommend to use conda environment instead of pip. See, there are several modules which do not give expected behaviour in pip (like pytorch).
Get the package installed using:
conda install -c conda-forge python-dateutil
returning the question, to get the package running it requires fulfillment of it's dependencies. If you are using python 3.7.3 its obvious that it may lack in some of the features of modern python 3.11 as a result you get the obvious error. The python package python-dateutil must have been configured according to the modern python language version.
Iam using python 3.11.1 and the package gets installed very perfectly. You may install old version of package or upgrade your python language version or use Conda as mentioned before.

pip install doesn't find my highest installed version of python

My problem is that when I try to install a product that requires python >= 3.7, the installer fails, saying that it could not find the required python version, even though I do have python 3.8 installed.
I'm running Ubuntu for Windows 10 (the MS-store product.)
It comes with python 3.6 installed.
From a clean ubuntu install, I
sudo apt update
sudo apt install python3.8
sudo apt install python3-pip
At this point the command "python" is not mapped (not available), but I can run "python3" to get python3.6 or "python3.8" to get that version.
pip3 reports that it is using python 3.6.
pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
So it appears that pip is not recognizing the python 3.8 that I have.
When I attempt my product install, it fails, indicating that
sudo pip3 install --verbose (mypackage name)
(... various messages...)
(requires-python:>=3.7) is incompatible with the pythonversion in use. Acceptable python versions are:>=3.7
Could not find a version that satisfies the requirement cbordplatform (from versions: )
No matching distribution found for (my package name)
How can I get pip3 to recognize my python3.8?
If you want to make sure that pip is using the correct version of Python, call it with the specific Python like this:
python3.8 -m pip ...

Updating 'pip' after configuring 'pip' to point to Homebrew's pip3 causes errors

After installing Python 3 using Homebrew and putting the Homebrew aliases (e.g. pip -> pip3) on my path
export PATH=/usr/local/opt/python/libexec/bin:$PATH
and then updating pip with
pip3 install -U pip
I get errors whenever I run pip:
pkg_resources.VersionConflict: (pip 19.1 (/usr/local/lib/python3.7/site-packages), Requirement.parse('pip==19.0.3'))
How do I configure my Homebrew Python 3 correctly with pip3 so that updates to pip (and other packages) work when the aliases provided with Homebrew's Python 3 are on my path?

Use or install different versions of python3 pip

I'm trying to install packages for my python 3.5.0 versus my python 3.4.3
I can run both by typing either python3.4 or python3.5
I have pip2 and pip3. I also ran the script sudo easy_install3 pip, which made me be able to use pip3.4 But I am still having trouble installing modules for python3.5. pip3 just installs for python3.4
I am looking to install termcolor for python3.5 and I am having no success. Can anyone help?
I am on Windows, and you appear not to be, but maybe the following will help.
If pip is in your system's equivalent of python35/Lib/site-packages, then python3.5 -m pip should run pip so that it installs into the 3.5 site-packages.
If you do not have pip in the 3.5 site-packages, copy its directory, along with its dependencies (pip....dist-info/, setuptools/, setuptools....dist-info/, and easyinstall.py) from the 3.4 site_packages.
Or, if pip3 or even pip3.4 is in python35/Scripts, run it with its full path name so you are not running the 3.4 version.

Resources