ModuleNotFoundError: No module named 'gi'

Hello, I’ve a problem.
My operating system: Linux Mint 21.1
Python version & source: python 3.11, build from source

Description of the problem:

I need the module gi for another program. (ModuleNotFoundError: No module named ‘gi’) I’ve tried to install it in different ways but every attempt failed:

sudo apt-get install python3-gi
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-gi is already the newest version (3.42.1-0ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pip3 install gi
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement gi (from versions: none)
ERROR: No matching distribution found for gi

sudo apt-get install python3-gi
python3-gi is already the newest version (3.42.1-0ubuntu1)

This version was built for python 3.10, so won’t qualify for your (local) python 3.11.

pip3 install gi
ERROR: No matching distribution found for gi

The package for Ubuntu’s python3-gi on PyPI is called PyGObject. You’ll probably need to install pkg-config and several *-dev packages to enable pip to build PyGObject.

pip3 install pkg-config
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement pkg-config (from versions: none)
ERROR: No matching distribution found for pkg-config
sudo apt install pkg-config
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
pkg-config is already the newest version (0.29.2-1ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pip3 install PyGObject
Defaulting to user installation because normal site-packages is not writeable
Collecting PyGObject
  Downloading PyGObject-3.42.2.tar.gz (719 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 719.5/719.5 kB 5.5 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pycairo>=1.16.0
  Using cached pycairo-1.23.0-cp311-cp311-linux_x86_64.whl
Building wheels for collected packages: PyGObject
  Building wheel for PyGObject (pyproject.toml) ... done
  Created wheel for PyGObject: filename=PyGObject-3.42.2-cp311-cp311-linux_x86_64.whl size=832893 sha256=68b345d70d08ace1ccfb865ad5605e5b2b38f9b80e3a67f6c4ed846e4aa10c2d
  Stored in directory: /home/philipp/.cache/pip/wheels/9c/47/08/e6c7c60f2060c2413e8d08be28fffdae1b9fcb5fd8583e9319
Successfully built PyGObject
Installing collected packages: pycairo, PyGObject
Successfully installed PyGObject-3.42.2 pycairo-1.23.0

It still not works

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.