Score:1

python3.8 and pip after upgrading to 22.04.2

me flag

I just updated 20.04 to 22.04, and I got some trouble with python versions. On 20.04, I had just python 3.8, and now on 22.04 it seems I have 3.10 only.

(base) giammi56@giammi56-T440p:~$ ls /usr/bin/python*
/usr/bin/python
/usr/bin/python3.10-config
/usr/bin/python3-pasteurize
/usr/bin/python3
/usr/bin/python3-config
/usr/bin/python-argcomplete-check-easy-install-script3
/usr/bin/python3.10
/usr/bin/python3-futurize
/usr/bin/python-argcomplete-tcsh3
(base) giammi56@giammi56-T440p:~$ apt list | grep python3.8
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libpython3.8-minimal/now 3.8.10-0ubuntu1~20.04.6 amd64 [residual-config]
python3.8-minimal/now 3.8.10-0ubuntu1~20.04.6 amd64 [residual-config]

ON 20.04, I aliased pip with pip3, but could this be problematic now?

(base) giammi56@giammi56-T440p:~$ pip --version
pip 23.0.1 from /home/giammi56/.local/lib/python3.10/site-packages/pip (python 3.10)
(base) giammi56@giammi56-T440p:~$ pip3 --version
pip 23.0.1 from /home/giammi56/.local/lib/python3.10/site-packages/pip (python 3.10)
(base) giammi56@giammi56-T440p:~$ pip3.8 --versionpip 23.0.1 from /home/giammi56/.local/lib/python3.10/site-packages/pip (python 3.10)

Clearly, some applications installed in pip do not work. Undervolt is the best example. The command is recognized, but not when sudo. Here the essential:

(base) giammi56@giammi56-T440p:~$ sudo undervolt --read
sudo: undervolt: command not found
(base) giammi56@giammi56-T440p:~$ undervolt
usage: undervolt [-h] [--version] [-v] [-f] [-r] [-t TEMP] [--temp-bat TEMP_BAT] [--throttlestop THROTTLESTOP]
[...]
(base) giammi56@giammi56-T440p:~$ locate undervolt
/etc/systemd/system/undervolt.service
/etc/systemd/system/hibernate.target.wants/undervolt.service
/etc/systemd/system/hybrid-sleep.target.wants/undervolt.service
/etc/systemd/system/multi-user.target.wants/undervolt.service
/etc/systemd/system/suspend.target.wants/undervolt.service
/home/giammi56/.cache/pip/wheels/ad/e5/e3/b8b0b993874dde746b5d3ffc16b122f15045fb98abd12d41ab/undervolt-0.3.0-py3-none-any.whl
/home/giammi56/.local/bin/undervolt
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info
/home/giammi56/.local/lib/python3.8/site-packages/undervolt.py
/home/giammi56/.local/lib/python3.8/site-packages/__pycache__/undervolt.cpython-38.pyc
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info/INSTALLER
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info/METADATA
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info/RECORD
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info/REQUESTED
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info/WHEEL
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info/entry_points.txt
/home/giammi56/.local/lib/python3.8/site-packages/undervolt-0.3.0.dist-info/top_level.txt
/usr/local/bin/undervolt
/usr/local/lib/python3.8/dist-packages/undervolt-0.3.0.dist-info
/usr/local/lib/python3.8/dist-packages/undervolt.py
/usr/local/lib/python3.8/dist-packages/__pycache__/undervolt.cpython-38.pyc
/usr/local/lib/python3.8/dist-packages/undervolt-0.3.0.dist-info/INSTALLER
/usr/local/lib/python3.8/dist-packages/undervolt-0.3.0.dist-info/METADATA
/usr/local/lib/python3.8/dist-packages/undervolt-0.3.0.dist-info/RECORD
/usr/local/lib/python3.8/dist-packages/undervolt-0.3.0.dist-info/WHEEL
/usr/local/lib/python3.8/dist-packages/undervolt-0.3.0.dist-info/entry_points.txt
/usr/local/lib/python3.8/dist-packages/undervolt-0.3.0.dist-info/top_level.txt

I don't know how to proceed. A suggested thread suggests a generic reinstallation. Should I upgrade all the python3.8 programs to 3.10? Is the alias still good? IN case I have multiple versions of python, I do I invoke a program from terminal/.desktop file/. service with the correct version? Any help would be deeply appreciated.

Score:2
jp flag

ON 20.04, I aliased pip with pip3, but could this be problematic now?

By "now" I assume you mean on Ubuntu 22.04 ... "Assuming you don't intend to later install and use Python2" ... This shouldn't be a problem as Python3 is the default and only currently available system Python.

Clearly, some applications installed in pip do not work. undervolt is the best example. The command is recognized, but not when sudo.

This is actually mostly irrelevant to the upgrade but relevant to the search path of both your user when running undervolt without sudo vs. root's search path when running it with sudo ... Executables for packages installed locally i.e. with just pip3 install .... are usually placed in ~/.local/bin/ and you can verify that with e.g. whereis undervolt and this is out of the scope of root's search path ... If on the other hand a package is installed globally i.e. with sudo pip3 install ... then their executables (among other differences) will be available in e.g. /usr/local/bin/ and thus will run fine with sudo.

Should I upgrade all the python3.8 programs to 3.10?

A good practice to insure compatibility is to indeed update modules/packages installed on a previous version of Python3 to what's available for the newly upgraded version using the pip3 -U option e.g. like so:

pip3 install -U undervolt

or with sudo if globally installed.

Please see: Python error in terminal

IN case I have multiple versions of python, I do I invoke a program from terminal/.desktop file/. service with the correct version?

There is the option to use the Python3 executable binary directly before the command you want to run and there is the option of running from within a dedicated virtual environment ... Please see:

Additional notice:

While pip list, pip install -U module/package or pip uninstall module/package will run on your default system Python version e.g. python3.10 in your case, different installed Python versions modules can also be handled separately i.e. per version like so:

#List installed modules for python3.10:
python3.10 -m pip list

#List installed modules for python3.8:
python3.8 -m pip list

#Install/update modules for python3.10:
python3.10 -m pip install -U module/package

#Install/update modules for python3.8:
python3.8 -m pip install -U module/package

#Uninstall modules for python3.10:
python3.10 -m pip uninstall module/package

#Uninstall modules for python3.8:
python3.8 -m pip uninstall module/package

#Run installed modules for python3.10:
python3.10 -m module/package

#Run installed modules for python3.8:
python3.8 -m module/package
Gi Na avatar
me flag
It works, but now I have undervot in lib 3.10 AND 3.8.. How can I test/find out which programs should be upgraded? Should I simply wait the moment something fails? Should I instead upgrade by default? Is there in case a standard procedure?
Raffa avatar
jp flag
@giammi56 I updated the answer with an **additional notice** for that.
Gi Na avatar
me flag
`python3.8 -m module/package`correctly says I don't have python3.8 (command not found). I do still have the libraries `/home/giammi56/.local/lib/python3.8/site-packages/` (2.7 GB) and `/usr/local/lib/python3.8/dist-packages/` (60 MB). At a visual inspection, many applications were not ported from 3.8 to 3.10. Should I perhaps reinstall 3.8, manage it via `update-alternatives` and port manually? Is there any guide on how to do that in a more programmatic/standard way?
Raffa avatar
jp flag
@giammi56 Changing your default system Python back to 3.8 or any other version for this matter will break your system, so don't do it at all ... if your system no longer has python3.8 installed then those modules under the old `~/.local/lib/python3.8/` directory might be no longer usable ... There are ways that would e.g. parse that directory for module names and then reinstall them into python3.10 automatically but they are not safe ... I recommend manually reinstalling those modules you need with `pip install -U ...` ... The same goes for the `/usr/local/lib/python3.8/` directory as well.
Raffa avatar
jp flag
@giammi56 I would suggest you start regularly saving your installed modules/packages to a file with e.g. `pip freeze > ~/my_file` ... This kind of backup list would be possible to safely automate its installation in a new Python version.
Gi Na avatar
me flag
What about installing a virtual environment for 3.8?
Raffa avatar
jp flag
@giammi56 A virtual environment should be safe and you can try copying the modules/packages `~/.local/lib/python3.8/site-packages/*` to your virtual environment directory under e.g. `env/lib/python3.8/site-packages/` and that might need some tweaks but should work ... You then might be able to activate that virtual env. and backup modules/packages from within the virtual env. with e.g `pip freeze > ~/my_file` then auto install and update those in the new python3.10 with e.g. `pip install -Ur ~/my_file` ... It's safe to try anyway and will most likely work ... Good thinking :)
Raffa avatar
jp flag
@giammi56 Or if you manage to make python3.8 installation work without altering the default system python3.10 … Then `python3.8 -m pip freeze > ~/my_file` and afterwards `pip install -Ur ~/my_file` would automatically port and update old modules/packages to python3.10
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.