I'm rather new to Ubuntu and I'm trying to run update-manager on Ubuntu 13.10. I get:
jacopo@jacopo-laptop:~$ update-manager
Traceback (most recent call last):
File "/usr/bin/update-manager", line 28, in <module>
from gi.repository import Gtk
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 27, in <module> from ._gi import _API
ImportError: No module named 'gi._gi'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 21, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/update-manager", line 28, in <module>
from gi.repository import Gtk
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 27, in <module>
from ._gi import _API
ImportError: No module named 'gi._gi'
As far as I have understood, this is a problem related to the fact that I should have python3.4 installed. I installed it in /usr/local/lib
, but I always get the same error. In this way I can't even upgrade to Ubuntu 14.04.
Reinstall
apt_pkg
using:The error is primarily because of library
apt_pkg.cpython-35m-x86_64-linux-gnu.so
not being present in/usr/lib/python3/dist-packages
.Removing and reinstalling should help.
for me the following steps worked:
the original solution is here: https://stackoverflow.com/questions/13708180/python-dev-installation-error-importerror-no-module-named-apt-pkg/36232975#36232975
The following solution worked for me:
If you get an error message saying too many levels of symbolic links as shown below:
Then you need to simply unlink the apt_pkg.so file. Use the following command:
And then use the command
Hope this helps!
For me this did the trick:
This problem actually is similar to this one: apt-get broken: No module named debian.deb822
The problem for me was that I installed python3.7 next to python3.6 and made it the default.
I manually run the following command:
so python3 now points to the correct version of python ... that solves the issue.
If you're trying to upgrade 13.10 to 14.04, try following these instructions. If you're just trying to update your current system from the command line, open a terminal and type the following:
This solution used to work for me after I had upgrade to either Python 3.6 or 3.7 and add-apt-repository stopped working:
Now I have Python 3.8 and add-apt-repository stopped working again. I found another, related SO question, with this answer that worked for me. It appears that the expected filename is now just
apt_pkg.so
, so you have to do this:The fact that the new expected filename is just
apt_pkg.so
is promising. Hopefully it means we won't have to keep doing this dance every time there's a new minor version of Python!I have managed to solve this by copying
apt_pkg.cpython-34m-i386-linux-gnu.so
to/usr/lib/python3/dist-packages/
from another desktop running Ubuntu 14.04 LTS. I have tried almost all possibilities found over internet like, purging python installation and then reinstalling, cleaning broken upgrade files etc, but ended up with no success.Just an advise: I avoid installing "my" python on /usr/local, but I have one dedicated directory per python version (e.g. in /opt) and I'm using virtual environments on my user account to use the python I need, which is activated by my .profile
By this approach, you will always avoid to change the python system expected configuration and dependencies.
Well, I know, it's too late for your case, but...