Ubuntu often uses the following command to add PPA sources:
sudo add-apt-repository ppa:XXX
Error: no module named ‘apt’_ pkg’ 。
This problem has been bothering me for a long time. Every time I want to solve it, I have been busy on the Internet for a long time without finding a solution
today I found the solution
Step 1: sudo GEDIT/usr/bin/apt add repository
We will find that the so-called “apt add repository” command is actually a python script, and the top line reads: #/ usr/bin/python3
This is a python 3 script
Step 2: sudo LS – L/usr/bin/python3
Display/usr/bin/python3 – > python3.5
Explain that on my Ubuntu, python3 is linked to python3.5. That’s the problem with Python 3.5
Step 3:
cd /usr/lib/python3/dist-packages/
ls apt_ pkg*
Display: apt_ pkg.cpython-34m-x86_ 64-linux-gnu.so
Note the word 34m, which means that only Python 3.4 can use this component safely! But our computer python3 is linked to python3.5
different Ubuntu versions do not necessarily display 34m, so you must check this file yourself. Then modify python3 to link to the corresponding version
At this point, the solution is very simple
Step 4:
sudo rm /usr/bin/python3
sudo ln – S/usr/bin/python3.4/usr/bin/python3 (according to the file name and version)
It’s done! Go and see if the apt add repository command can be used
The ultimate mystery
sudo apt-get remove –purge python-apt
sudo apt-get install python-apt -f
sudo find/-name “apt_ pkg.cpython-35m-x86_ 64-linux-gnu.so”
cd /usr/lib/python3/dist-packages/
sudo cp apt_ pkg.cpython-35m-x86_ 64-linux-gnu.so apt_ pkg.cpython-36m-x86_ 64-linux-gnu.so (depending on the file name version)
Similar Posts:
- [Solved] Python3 Error: ModuleNotFoundError: No module named ‘_bz2’
- Ubuntu1.8 Install python3.7pip Error: “subprocess.CalledProcessError…lsb_release”
- Bpython ImportError: No module named _curses [How to Solve]
- Error in python2.7 installation of pycrypto Library [How to Solve]
- [Solved] rosrun import rospy Error: ImportError: No module named yaml
- [Solved] pip and setuptools upgrade Error: Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-fH0Feg/pip/
- Ubuntu18.04 (Python3.9) Error: ImportError: Cannot import name ‘sysconfig’ from ‘distutils’
- [Solved] docker-compose:No module named ssl_match_hostname; ImportError: No module named shutil_get_te…
- [Solved] Could not install packages due to an Environment Error: [Errno 13] Permission denied
- Under Ubuntu system, selenium opens the Firefox browser and prompts’ unable to find a matching set of capabilities. And message: connect