How to install gi for anaconda python3.6
in Ubuntu 16.04 I have python2.7, python3.5 and python3.6. Anaconda is using python3.6. I can import gi on 2.7 and 3.5, but I can't in 3.6. I created the link as suggested here but I still get an error.
gio@gio-XPS-13-9343:~$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.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/gio/anaconda3/lib/python3.6/site-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: cannot import name '_gi'
>>> 1 1 Answer
I have had the very same problem today and what worked for me is the following:
First, create the link, as suggested in the stackoverflow post you cited (assuming that anaconda is installed under /home/your_user/anaconda3)
ln -s /usr/lib/python3/dist-packages/gi /home/your_user/anaconda3/lib/python3.6/site-packages/
Secondly, navigate into the gi folder that you just linked, within your anaconda directory and rename a copy of the two .so files to fit the python-version of anaconda (in my case from 3.4 to 3.6)
cd /home/your_user/anaconda3/lib/python3.6/site-packages/gi/
sudo cp _gi.cpython-34m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.soand
sudo cp _gi_cairo.cpython-34m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.soFinally, the import gi worked accordingly within my anaconda environment.
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> 1 More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"