0

Recently I upgraded to Ubuntu 22.04 but it seems that my default python is still 3.8 instead of 3.10. It seems that both 3.9 and 3.10 have been installed already though. I am afraid that I installed python 3.8 manually in the wrong way a long time ago. I spent days already on this problem, but I cannot figure out where the 3.8 has been configured as default. *

Update: problem solved! I had installed python from source, into the /usr/bin/local directory. Hence the system ignored the newer python versions in user/bin. I had to remove the files from local and now everything works smoothly again


sudo update-alternatives --config python

  update-alternatives: error: no alternatives for python

ls /usr/bin/python*

 /usr/bin/python     
 /usr/bin/python3.10  
 /usr/bin/python3-config
 /usr/bin/python2    
 /usr/bin/python3.10-config  
 /usr/bin/python3-futurize
 /usr/bin/python2.7  
 /usr/bin/python3.9          
 /usr/bin/python3-pasteurize
 /usr/bin/python3    
 /usr/bin/python3.9-config

which python3 (points to local, instead of the above directory with all python versions)

 /usr/local/bin/python3

python3 --version

Python 3.8.0

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:    22.04
Codename:   jammy
TheCook
  • 1
  • 1
  • 3
  • 1
    Can you do a `which python3` and then go check that directory and see if other versions are hanging out in that same directory? – JNevill Jun 13 '22 at 15:42
  • How did you install Python 3.8 manually? – albert Jun 13 '22 at 15:44
  • Does this answer your question? [How to make python3 command run Python 3.6 instead of 3.5?](https://stackoverflow.com/questions/43743509/how-to-make-python3-command-run-python-3-6-instead-of-3-5) – albert Jun 13 '22 at 15:45
  • @JNevill thanks. This points to /usr/local/bin where only python3.8 is available. However, in the /usr/bin/ directory I can see also 3.9 and 3.10. Could it be that i have installed python in the wrong directory? – TheCook Jun 13 '22 at 15:55
  • It's not wrong; `/usr/bin` is where I would expect things installed by your local package manager, and `/usr/local/bin` is where I would expect to see things installed by a local user. The issue is (likely) that you have `/usr/local/bin/` before `/usr/bin` in your `PATH`, so `python3` resolves to `/usr/local/bin/python3` instead of `/usr/bin/python3`, regardless of what `/usr/bin/python3` refers to. Honestly, you could simply remove `/usr/local/bin/python3`, and the problem would be resolved...(1/2) – chepner Jun 13 '22 at 16:09
  • ... There may be a lot of *other* related files under `/usr/local` to remove as well, but nothing installed by the package manager should care about any of them. (2/2) – chepner Jun 13 '22 at 16:10
  • Perfect. So you have all the versions you want. Now... as always happens with python, you have to manage all of them to use the one you want. Do a `ls -lh /usr/bin/python3` and likely that thing is a symbolic link into a version in your `/usr/bin` directory. You can just change the symbolic link to point to whichever version you want. – JNevill Jun 13 '22 at 16:10
  • The reason to use a package manage is because it knows how to *uninstall* anything it installs. (If `/usr/local/bin/python3` was installed with `make install` from a particular source distribution, `make uninstall` should work, assuming you provide it the correct installation prefix.) – chepner Jun 13 '22 at 16:12
  • I removed the python3 files from /local/bin/ and now indeed `ls -lh /usr/bin/python3` and `which python3` point to the correct python3.10 folders. Thanks for the help! I will use the package manager next time – TheCook Jun 13 '22 at 16:44

0 Answers0