Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python add-apt-repository: ImportError: No module named 'apt_pkg'

Tags:

When I try:

sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next 

in Ubuntu, the terminal show this error message:

Traceback (most recent call last):  File "/usr/bin/add-apt-repository", line 11, in <module>     from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler   File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in <module>     import apt_pkg ImportError: No module named 'apt_pkg' 

I have two version of python, one is 2.7 the other is 3.5 .

How can I install this package on python3.5?

like image 455
ding Avatar asked Feb 22 '17 08:02

ding


People also ask

What is apt_pkg?

The apt_pkg extensions provides a more low-level way to work with apt. It can do everything apt can, and is written in C++. It has been in python-apt since the beginning.

How to fix no module named apt_ pkg?

Importerror no module named apt_pkg is mainly because of python-apt package. Either python-apt package is not installed or is incompatible. So the fix for this error (no module named apt_pkg) is straight to reinstall/ upgrade the python-apt package.


1 Answers

I had something quite different than this. Mine failed with

No module named 'softwareproperties'

My solution is:

sudo vim /usr/bin/add-apt-repository Change package header from `python3` to `python3.4` (or lower) 

This may happen when you recently upgraded or added another python3 package.

like image 69
Yonatan Kiron Avatar answered Sep 21 '22 18:09

Yonatan Kiron