<에러해결>

[ERROR] Python 버전바꾸고 sudo apt-get update 에러 / ModuleNotFoundError: No module named 'apt_pkg'

peanut0613 2022. 4. 9. 16:08

python3.6 -> python3.7로 바꾸고 나타난 문제

Traceback (most recent call last):
  File "/usr/lib/cnf-update-db", line 8, in <module>
    from CommandNotFound.db.creator import DbCreator
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code

 

아래 명령어로 해결 (https://askubuntu.com/questions/480908/problem-with-update-manager-no-module-named-apt-pkg-in-ubuntu-13-10-having-i)

apt-get remove  python3-apt
apt-get install python3-apt
sudo apt-get install --reinstall python3-apt