ubuntu apt-get update error:ModuleNotFoundError: No module named ‘apt_pkg‘

After ubuntu upgrades python, it may cause errors in apt-get update, apt-get upgrade and other commands: the apt_pkg module cannot be found,

The general solution is:

1. Enter the directory first: cd /usr/lib/python3/dist-packages/ 

2、查找apt_pkg*.so:ll *apt_pkg*.so

      A similar library (related to the machine and installation package) will be found: apt_pkg.cpython-36m-x86_64-linux-gnu.so

       But the apt_pkg.so file cannot be found,

3. One cp is enough: sudo cp apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pgk.so

4. Then try again: sudo apt-get update and sudo apt-get upgrade

 

Guess you like

Origin blog.csdn.net/lianshaohua/article/details/108606353