2

I royally screwed up my PATH variable last night, thankfully a user called Icarus helped me rebuild it here.

However it's not fully fixed and I receive the same (or maybe very similar) error that I get in the previous post when I attempt to run sudo apt-get update

Error message:

Hit:1 http://ppa.launchpad.net/geany-dev/ppa/ubuntu bionic InRelease
Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                                                    
Hit:3 http://ppa.launchpad.net/hvr/ghc/ubuntu bionic InRelease                                                                                       
Hit:4 http://gb.archive.ubuntu.com/ubuntu bionic InRelease                                                                                           
Hit:5 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                                                   
Hit:6 http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu bionic InRelease                                                           
Hit:7 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease                                                                       
Hit:8 https://deb.nodesource.com/node_12.x bionic InRelease                                                                                
Hit:9 http://packages.microsoft.com/repos/vscode stable InRelease                                                    
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'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, 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 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
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

Retsek
  • 343
  • The default sudo configuration on Ubuntu ignores the invoking user's PATH in favor of its own secure_path. In any case, I don't think PATH is used for locating python modules. What is the output of dpkg -C python3-apt? – steeldriver Feb 21 '20 at 15:36
  • @steeldriver dpkg -C python3-apt gives no output at all. Sorry if the tags are wrong and it has nothing to do with the PATH variable. – Retsek Feb 21 '20 at 15:41
  • 1
    @GAD3R I tried to switch to python2 (the link was a little bit unclear and a lot of the commands they spoke about threw errors for me) but alias python="python2" worked but when I ran sudo apt update I got the same error again – Retsek Feb 21 '20 at 15:47
  • Answerers may enjoy https://askubuntu.com/q/480908/43344 . https://askubuntu.com/q/1041151/43344 , https://askubuntu.com/q/1187729/43344 , https://askubuntu.com/q/1176006/43344 , and https://askubuntu.com/q/1176105/43344 . – JdeBP Feb 21 '20 at 16:04
  • What is the output of type python ; ls -l $(type -p python) ? – icarus Feb 21 '20 at 22:41
  • @icarus Hi Icarus thank-you for coming to my aid again, thankfully however someone else fixed it irl for me, not 100% sure what he did, something about a symbolic link? – Retsek Feb 22 '20 at 10:12
  • 2
    @Retsek you should ask them and post it as an answer if possible! – not my real name Feb 22 '20 at 19:29
  • This fixed things for me: https://bugs.launchpad.net/ubuntu/+source/command-not-found/+bug/1876034/comments/2 – Daniel S. Sterling Oct 24 '20 at 07:59

0 Answers0