You are not logged in.

#1 2021-10-25 07:05:55

3x071c
Member
Registered: 2021-08-29
Posts: 5

Python can't import gi module

Many (graphical) python utilities rely on the 'gi' API (PyGObject).
I wiped some pip and pacman 'python-' modules in an effort to clean up and now importing gi leads to the following error message:

$ python   
Python 3.9.7 (default, ...) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python3.9/site-packages/gi/__init__.py", line 40, in <module>
    from . import _gi
ImportError: libffi.so.7: cannot open shared object file: No such file or directory

I've already reinstalled all the modules I removed, but any script using gi still crashes. Can somebody help me out of this mess?

Offline

#2 2021-10-25 09:00:16

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,300

Re: Python can't import gi module

You are loading a user local pygobject library rather than the one from the system. Rebuild your venv or get rid of the local installation alltogether if you don't actively use it.

Last edited by V1del (2021-10-25 09:01:41)

Offline

#3 2021-10-25 20:23:57

3x071c
Member
Registered: 2021-08-29
Posts: 5

Re: Python can't import gi module

V1del wrote:

You are loading a user local pygobject library rather than the one from the system. Rebuild your venv or get rid of the local installation alltogether if you don't actively use it.

I deleted the local install and everything's working again now. I wonder how it got there in the first place? Thanks!

Offline

#4 2021-10-26 06:29:20

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,300

Re: Python can't import gi module

Stuff like this usually happens from pip installing/setting up a venv. If you don't have a particular reason for that you should always first opt for pacman packages to prevent compat issues like these.

Offline

Board footer

Powered by FluxBB