0

I am unable to update repository using "add-apt-repository" using-

xxx@yyy-HP-ProBook-430-G3:~/Downloads/packages$ sudo add-apt-repository ppa:ondrej/php5-5.6

I am getting the following python error:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, 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 23, 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/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

I have already purged and installed python-apt as described in python-dev installation error: ImportError: No module named apt_pkg but I am still unable to fix the error. I am using Ubuntu-16.04 having default python(2.7.12) with along with Python 3.5.2 and Python 3.6.3.

Can any one please help me to fix the issue.

Monti Chandra
  • 432
  • 5
  • 21
  • Possible duplicate of [python-dev installation error: ImportError: No module named apt\_pkg](https://stackoverflow.com/questions/13708180/python-dev-installation-error-importerror-no-module-named-apt-pkg) – acsrujan Dec 27 '17 at 06:12
  • I have already follow this. but still not able to fix – Monti Chandra Dec 27 '17 at 06:40
  • Did you try another solutions from that post? f.e. `cd /usr/lib/python3/dist-packages`, `sudo ln -s apt_pkg.cpython-{35m,34m}-x86_64-linux-gnu.so` – Vasily Bronsky Dec 27 '17 at 08:00
  • Yes, but now i am getting following error? Traceback (most recent call last): File "/usr/bin/add-apt-repository", line 11, in from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' – Monti Chandra Dec 27 '17 at 11:32

0 Answers0