3

I recently updated from 15.10 to 16.04 and now my python3 seems to be messed up.

Before the upgrade I had python3.4 and python3.5.1(manually) installed. The upgrade removed python3.4 and replaced it with python3.2 and python3.1.
The new python3.5.1 removed my python3.5.1 installtion.

But now I am facing a lot of issues:

  • check this question
  • comand-not-found does not work anymore and crashes with this traceback (1)

  • if I try to run commmand-not-found with python3.2 (2)

I stripped a few more stuff, as it is always the same.

I do not want to use the old python3 versions, so how can I fix this?
And why is there python3.1?

(1)

 me@my-machine:~$ whareis systemd     
 Traceback (most recent call last):
   File "/usr/lib/command-not-found", line 27, in <module>
     from CommandNotFound.util import crash_guard
 ImportError: No module named 'CommandNotFound'

(2)

Traceback (most recent call last):
  File "/usr/lib/python3.2/dbm/gnu.py", line 6, in <module>
    from _gdbm import *
ImportError: No module named _gdbm

2 Answers2

2

Solution: Unlike I mentioned before my python3.5.1 installation was not removed by the update. It was still under /usr/local/bin/python3.5.

Tracing the Error: I wrote a few debug lines into /usr/lib/python3.5/_sysconfigdata.py:

print("python-version", sys.version_info)
print("python-gcc-version",sys.version)
print("python-executable",sys.executable)

The output was different between calling /usr/bin/python3 and rhythmbox, but the python-executable was in both ways /usr/bin/python3

Then I searched for the wrong installation using whereis python3 and removed /usr/local/bin/python3.5

Then I purged and reinstalled python3 and ran apt install -f.
So this Error disappeared.

Remember: never install stuff from source, if it might be in the repos sometime or, at least remove it before your package manager installs it.

1

Saw the same error in Ubuntu 16.04 with two installations of Python3 (3.5.2 and 3.7.3):

$ junk
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 27, in <module>
    from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'

I didn't need python 3.5.2. So, removing it by doing the following resolved the error for me:

sudo apt-get remove --purge python3*
sudo apt autoremove

Then, I see command not found as expected:

$ junk
junk: command not found