No module named gi
Asked Answered
V

5

7

i have try all the possible command given below:

pip install pgi , pip install PyGObject , pip install python-gi

Still not able to install the module in python . Installed python 3.7 also try to make a virtual environment but not able to install the module .

#import cv2
import gi
import numpy as np

gi.require_version('Gst', '1.0')
from gi.repository import Gst
Vasya answered 6/3, 2022 at 11:11 Comment(5)
did u tried python3-gi?Suavity
There are MANY (as in thousands!) questions about ModuleNotFoundError already. Could you please try to make this question unique and clear? You wrote that you already tried a virtual environment. That's good. Could you edit your question and describe the exact commands you used to create and activate that environment, the exact command you used to run the Python script, and the exact output of that command? With that information, it will be pretty simple for others to reproduce the issue and answer the question.Durazzo
Note that this answer already provides some explanation and solutions for installing and using Python packages in WIndows. This solution might apply to your question as well, but maybe not. It's hard to tell without more information. NB: Please also add which module you are trying to use (link to pypi?)Durazzo
I think this seems to fully answer the question: Python cannot install PyGObject If so, this question should be closed as duplicate.Durazzo
NB: official installation instructions for PyGObject are hereDurazzo
A
29

Try this:

sudo apt install libcairo2-dev libxt-dev libgirepository1.0-dev

pip install pycairo PyGObject
Altruistic answered 6/3, 2022 at 11:11 Comment(3)
can it work on windows ?Vasya
This error comes up in the last stage: ModuleNotFoundError: No module named 'cairo._cairo'Jeb
I also needed sudo apt install libpython3.10-dev (replace 3.10 with the version of python you are using).Calais
B
3

In an Arch based distro, this worked for me. You can use another AUR helper such as Pamac or Yay instead of Paru.

paru -S gobject-introspection 
pip install pygobject
Betimes answered 10/10, 2022 at 15:55 Comment(1)
On some Arch setups with externally managed Python environments, installing the pacman package python-gobject instead of running that pip commands is necessitated.Sabadilla
A
1

On a RHEL8 variant (Rocky Linux 8) the resolution was to use /usr/bin/python3.6m instead of regular python3.6 (or any of the other Python variants I had installed which did not end with an 'm').

More info on 'm' variants can be found here: What's the difference between python3.<x> and python3.<x>m

Aerophyte answered 6/1 at 8:12 Comment(1)
Confirmed on RHEL 8.6 (Ootpa)Erena
R
0

I got my python setup properly trashed on Ubuntu 20.04. I was trying to use apt-add-repository and got "ModuleNotFoundError: No module named 'gi'". I had already installed software-properties-common and python3-gi using apt. For me the answer was

sudo apt-get --reinstall install python3-gi
Rhodarhodamine answered 18/10, 2023 at 20:39 Comment(0)
N
0

Bit late on the answer but I am having the same problem in 2023. I have the same problem with a python installation as user in /usr/local/bin instead of /usr/bin. Hope this helps someone

Nationality answered 29/12, 2023 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.