Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.1K
Vistas
ImportError: cannot import name '_gi' from partially initialized module 'gi' (most likely due to a circular import)

Looks like I have broken my python installation when I wanted to switch to python 3.8. Using Ubuntu 18.04. Trying to use the gi, gives the following error:

$ python
Python 3.8.1 (default, Dec 31 2019, 18:42:42) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> from gi.repository import GLib, Gio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
    from . import _gi
ImportError: cannot import name '_gi' from partially initialized module 'gi' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gi/__init__.py)

Tried running update-alternatives for python, but it tells me there is only one python alternative configured (3.8).

Tried to reinstall python3-gi and python3.8. Still the same problem

over 4 years ago · Santiago Trujillo
6 Respuestas
Responde la pregunta

0

Have same issue, can't load module from script folder. In my case work if i changing workdir for example (but only for inline command):

cd /tmp; python -c 'from gocd import Server'
echo $?
0

After copy script to /tmp, it's does't work

cp gocd.py /tmp
cd /tmp; python -c 'from gocd import Server'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/gocd.py", line 3, in <module>
    from gocd import Server
ImportError: cannot import name 'Server' from partially initialized module 'gocd' (most likely due to a circular import) (/tmp/gocd.py)
over 4 years ago · Santiago Trujillo Denunciar

0

Install gi for python 3.8: python3.8 -m pip install pgi Then, instead of import gi use:

import pgi
pgi.install_as_gi()
from gi.repository import GLib, Gio

Alternatively, you can force install PyGObject for python 3.8:

sudo python3.8 -m pip install --ignore-installed PyGObject

which should allow one to from gi import ... as before.

over 4 years ago · Santiago Trujillo Denunciar

0

I had the same issue. I linked python3 to python3.6, for me it was pointing to 3.8. That solved the issue.

cd /usr/bin/
rm python3
ln -s python3.6 python3

Thats all. Now my system started working fine.

over 4 years ago · Santiago Trujillo Denunciar

0

Found answer here https://bugzilla.redhat.com/show_bug.cgi?id=1709787:

The cause is - /usr/lib64/python3.8/site-packages/gi/_gi.cpython-38m-x86_64-linux-gnu.so has incorrect name:

sh-5.0# python3 -c 'from gi.repository import GLib' Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.8/site-packages/gi/init.py", line 42, in from . import _gi ImportError: cannot import name '_gi' from 'gi' (/usr/lib64/python3.8/site-packages/gi/init.py) sh-5.0# mv /usr/lib64/python3.8/site-packages/gi/_gi.cpython-38m-x86_64-linux-gnu.so /usr/lib64/python3.8/site-packages/gi/_gi.cpython-38-x86_64-linux-gnu.so sh-5.0# python3 -c 'from gi.repository import GLib'

Note that since 3.8.0a4, the "m" is not supposed to be there. Is it somehow hardcoded?

sh-5.0# python3-config --extension-suffix .cpython-38-x86_64-linux-gnu.so

in my case it was

$ sudo ln -s /usr/lib/python3/dist-packages/gi/_gi.cpython-35m-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/gi/_gi.cpython-38-x86_64-linux-gnu.so
$ sudo ln -s /usr/lib/python3/dist-packages/gi/_gi_cairo.cpython-35m-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/gi/_gi_cairo.cpython-38-x86_64-linux-gnu.so
over 4 years ago · Santiago Trujillo Denunciar

0

For me the workaround was to create a symlink:

cd /usr/lib/python3/dist-packages/gi/
sudo ln -s _gi.so _gi.cpython-38-x86_64-linux-gnu.so

and it solved the problem for me.

over 4 years ago · Santiago Trujillo Denunciar

0

The reason of this error is that this app can't find the matched Python version of _gi_cairo.cpython-(version)-x86_64-linux-gnu.so.
Normally, this unmatched situation is caused by some wrong mixed usage of different versions of Python.

So basically, you can try to switch your Python version ( to the default version of your OS). Or you can go to '/usr/lib/python3/dist-packages/gi' and create a new .so library file:

cp _gi_cairo.cpython-(old version)-x86_64-linux-gnu.so _gi_cairo.cpython-(new version)-x86_64-linux-gnu.so

or

ln -s _gi_cairo.cpython-(old version)-x86_64-linux-gnu.so _gi.so
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda