deadsnakes / issues

Issues for https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
86 stars 6 forks source link

python3.7 on Ubuntu22.04 error cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py) #222

Closed mattjwarren closed 2 years ago

mattjwarren commented 2 years ago

description

python3.7 installed from deadsnakes PPA into Ubuntu22.04 with sudo apt install python3.7

After installing python3.7 for ubuntu22.04 I have the problem;

root@ubuntu-1:/# python3.7 Python 3.7.13 (default, Apr 24 2022, 01:06:43) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

import gi Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3/dist-packages/gi/init.py", line 40, in from . import _gi ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/init.py)

Using the system python, 3.10 this import is succesful.

os information

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:        22.04
Codename:       jammy

uname -a

Linux ubuntu-1 5.15.0-40-generic #43-Ubuntu SMP Wed Jun 15 12:54:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
asottile commented 2 years ago

from the PPA page:

Python modules in the official Ubuntu repositories are packaged to work with the Python interpreters from the official repositories. Accordingly, they generally won't work with the Python interpreters from this PPA. As an exception, pure-Python modules for Python 3 will work, but any compiled extension modules won't.

mattjwarren commented 2 years ago

This may be a red herring, but some googling suggested I try

root# python3.7 -m pip install pycairo Requirement already satisfied: pycairo in /usr/lib/python3/dist-packages (1.20.1) root# python3.7 -m pip install PyGObject Requirement already satisfied: PyGObject in /usr/lib/python3/dist-packages (3.42.0) Requirement already satisfied: pycairo>=1.16.0 in /usr/lib/python3/dist-packages (from PyGObject) (1.20.1)

This appears that even though I am calling python3.7 -m pip install .... It is being satisfied with packages installed in dist-packages, where I understood that should only be valid for the system python python3.10 ?

so python3.7 import gi is attempting to import compiled c modules from the system python installation in dist-packages, which would likely fail as they are from a python3.10 compilation?

asottile commented 2 years ago

why not global pip

mattjwarren commented 2 years ago

I am relying on python3.7 because the project requires tensorflow 1.15 which is not supported in python above 3.7

mattjwarren commented 2 years ago

Ahh I see your above comment, give me a moment to read through it

mattjwarren commented 2 years ago

I thought to install my requirements for python3.7, I must use python3.7 -m pip

it appears I am thoroughly confused by managing extra python versions other than the system python. I shall continue reading some more!