2

Cause:

I did the mistake of upgrading my system's (Ubuntu 20.04.6 LTS) python version from 3.10 to 3.12.

Issue:

Since then, my terminal wouldn't open.

And when opening a virtual terminal (CTRL+ALT+F3) it first displays ModuleNotFoundError: No module named 'apt__pkg', and then it (the virtual terminal) keeps on working normally.

Attempted solutions

I tried leaving python3.10 as the only python-alternatives and tried adding other alternatives (python3.8), but the issue persists.

I added alias python='usr/bin/python3' to my .bashrc

I commented the export $PATH=... by anaconda

The only installed version right now is 3.10.6. python -V as well as python3 -V give 3.10.6

I did as the comments suggested (reverting to 3.8) since it is the actual default for FocalFossa

Toolchain Upgrades ️

Ubuntu 20.04 LTS comes with [...] Python 3.8.2, [...].

Source: FocalFossa/ReleaseNotes

But the terminal still doesn't work.


Figures:

Recovery mode

recovery

Updates

updates

.bashrc

.bashrc

python -V

python -V

update-alternatives

update-alternatives


Not duplicate of this, because: links

Omar Trkzi
  • 41
  • 5
  • You can have different python3 versions installed, but you cannot change the default if you wish your Ubuntu Desktop system to perform correctly. Return the default version to what it was. – guiverc Nov 22 '23 at 10:37
  • @guiverc Yes, that's what I am trying to achieve – Omar Trkzi Nov 22 '23 at 10:43
  • @guiverc Unfortunately it doesn't, since in my case /usr/bin/python3 points to /etc/alternatives/python3 which in turn points to /usr/bin/python3.10, all of which do exist. – Omar Trkzi Nov 22 '23 at 10:44
  • Ubuntu 22.04 LTS uses 3.10; your question says you're on 20.04 where 3.10 should not be the default for apps like gnome-terminal to open. Return your python3 defaults to what is expected for your release (ie. 20.04 if that's what you're using) – guiverc Nov 22 '23 at 10:47
  • Ubuntu 20.04 = Python 3.8 (not 3.10). Change the default to 3.8, and apt should begin working again. If it doesn't, the you in for laborious troubleshooting...or a reinstall. You have learned the Second Rule of Debian-based Systems: Don't change the default Python. – user535733 Nov 22 '23 at 10:48
  • @user535733 You are correct, the default version of python for 20.04 is indeed 3.8, I reverted it, however the issue persists (even after restarting the machine) – Omar Trkzi Nov 22 '23 at 11:01
  • If "module not found" persists when running Python 3.8, then verify that running python3 in shell really, truly runs the Python 3.8 interpreter instead of a different version. – user535733 Nov 22 '23 at 11:17
  • @user535733 it does i tested with print("Hello") and with python -V and python3- V both of which give 3.8.10. Do you think that it should be exactly 3.8.2 ? If so how to do so ? – Omar Trkzi Nov 22 '23 at 11:23
  • How did you get Python 3.8.10? That's not in the Ubuntu 20.10 repositories. – user535733 Nov 22 '23 at 11:25
  • @user535733 I am not sure, i assume it came with it. Perhaps I should reinstall it. – Omar Trkzi Nov 22 '23 at 11:27
  • @Raffa The answer there does tell "how to safely revert the version" but not actually how to do it. – Omar Trkzi Nov 22 '23 at 13:23
  • The best way to revert what you have done, is just reverse whatever you've done. As we don't know what you did, we can't tell you what needs correcting. Ubuntu 20.04 LTS python3 will upgrade to python3.8 | 3.8.10-0ubuntu1~20.04.8 | focal-security | source, amd64, arm64, armhf, i386, ppc64el, riscv64, s390x which will not impact working function; but you need to revert changes you did in trying to change default. A non-destructive re-install maybe the fastest if you don't know what you did. – guiverc Nov 22 '23 at 21:19
  • @user535733 I ended up backing my data and re-installing the OS, notice: 3.8.10 is indeed the version that comes by default with Ubuntu 20.04, thank you all for your time – Omar Trkzi Nov 26 '23 at 06:41

0 Answers0