0

The authentication window pops-up but then I'm getting a bunch of errors (in the console) and nothing happens. Looked up similar issues on the Internet and tried the following:

  • updating the OS
  • installing: python-gobject, python-gi, dev-tools

Thanks in advance for any advice.

Traceback (most recent call last):
  File "/usr/share/gufw/gufw/gufw.py", line 21, in 
    from gufw.view.gufw  import Gufw
  File "/usr/share/gufw/gufw/gufw/view/gufw.py", line 18, in 
    import gi
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
    from . import _gi
ImportError: cannot import name '_gi'
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 
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in 
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in 
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in 
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in 
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/share/gufw/gufw/gufw.py", line 21, in 
    from gufw.view.gufw  import Gufw
  File "/usr/share/gufw/gufw/gufw/view/gufw.py", line 18, in 
    import gi
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
    from . import _gi
ImportError: cannot import name '_gi'
Maddak
  • 1
  • 1
  • 1

3 Answers3

1

I've encountered the same problem, and it's really not easy to find a good fix (they're really very few results on google), so my solution is to fully reinstall pygobject in accordance with https://pygobject.readthedocs.io/en/latest/getting_started.html

sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0  
sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0  
pip3 install pycairo  
pip3 install PyGObject

(You need to apt install python3-pip beforehand.)

It worked perfectly for me.

lp177
  • 11
0

Recently I faced this kind of error.

In my case I'm using Kubuntu 18.04 and the official repositories only have python 3.6.

Some time ago I installed Python 3.7 from sources (doing make install, etc...) as a requirement of a project.

When I installed Python the system overrides the default path to python3 executable with the fresh installation.

So to fixed this issue I removed the local system executable of python3 (--> python3.7) and create it again with the path to python3.6.

sudo rm -rf /usr/local/bin/python3

sudo ln -s /usr/bin/python3.6 /usr/local/bin/python3

I hope this helps someone!

0

Not sure what, if anything you might have done to cause this. Upgrade Ubuntu? How did you install UFW? From the repos?

At any rate , that is sort of a non-specific error and might occur with other packages as well.

As a first step try updating (“dist-upgrade”) to see if you have outdated or held packages.

sudo apt-get update
sudo apt-get dist-upgrade -f

If that fails as a second step try re-installing python-apt

See https://packages.ubuntu.com/zesty/python-apt

sudo apt-get install --reinstall python-apt

You could shorten those two commands, but I hope it is more clear to demonstrate the reinstallation of python-apt.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Panther
  • 102,067
  • I've installed GUFW simply with: sudo apt-get install gufw unfortunately none of the steps you provided solved the problem. Upgrading Ubuntu had no effect either. What helped was a complete reinstall of the system. My guess is I must have messed something up with the default python. Thanks for looking into this – Maddak Sep 20 '17 at 19:36