1

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.

giammi56
  • 140

1 Answers1

2

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

Raffa
  • 34,963