1

I am new to ubunutu and am trying to use some scientific software, namely pymatgen and phonopy. When running phonopy I get the following output. I tried to then update all of my packages, including python, but when I performed apt-get update I get the following output and errors below. Should I just reinstall ubuntu or python?

Phonopy errors

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, 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/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

apt-get update errors

Hit:2 http://repository.spotify.com stable InRelease                                                                  
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease                                                            
Hit:4 http://archive.canonical.com/ubuntu bionic InRelease                                                            
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                    
Hit:6 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                     
Hit:7 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease                           
Get:1 https://github.com/cmsi/MateriAppsLive/wiki/UsingMateriAppsInDebianWheezy-en bionic InRelease
Err:1 https://github.com/cmsi/MateriAppsLive/wiki/UsingMateriAppsInDebianWheezy-en bionic InRelease
  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
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: Failed to fetch https://github.com/cmsi/MateriAppsLive/wiki/UsingMateriAppsInDebianWheezy-en/dists/bionic/InRelease  Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: The repository 'https://github.com/cmsi/MateriAppsLive/wiki/UsingMateriAppsInDebianWheezy-en bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
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
4
  • Did you make changes (or upgrade away from) the original system-provided version of Python/Python3? If so, revert to the system-provided version.
    – user535733
    Nov 1 '19 at 20:08
  • I installed python 3 and believe that I set it to a default but I am unsure how to revert back to the original python. I am not finding anything online on how to do that. I have python3.6, python3.7, and python 2.7.15 installed
    – NKUP
    Nov 1 '19 at 23:21
  • If you recall exactly what you installed, uninstall it. Do not guess. Not sure what you mean by "I set it to a default."
    – user535733
    Nov 3 '19 at 2:58
  • Does this answer your question? ModuleNotFoundError: No module named 'apt_pkg' error
    – karel
    Feb 1 '20 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.