python3
is my local Anaconda version of python, while python3.4
is the system one. I can import gi
module with python3.4
(probably because i installed it with sudo apt-get install python3-gi
) but python3
doesn't see it:
$ python3 -c 'import gi' Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named 'gi' $ python3.4 -c 'import gi' $ python3 --version Python 3.5.1 :: Anaconda 4.0.0 (64-bit) $ python3.4 --version Python 3.4.3 $ which python3 /home/kossak/anaconda3/bin/python3 $ which python3.4 /usr/bin/python3.4 $
How should i install gi
for Anaconda python? Or maybe i can somehow import sysem-wide modules?
My os:
System: Kernel: 3.19.0-32-generic x86_64 (64 bit gcc: 4.8.2) Desktop: Cinnamon 2.8.8 (Gtk 2.24.23) dm: mdm Distro: Linux Mint 17.3 Rosa
If you're using conda virtualenv for python-3, you can use
$ conda install -c conda-forge pygobject
in your virtualenv
You can read more about this on: https://anaconda.org/conda-forge/pygobject
This is how you do it: (example for Linux Mint and python3)
First install gi
module using your distro package manager. For Linux Mint it would be:
sudo apt-get install python3-gi
Then run your distro python to check where the module is located:
$ /usr/bin/python3 Python 3.5.2 (default, Sep 10 2016, 08:21:44) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>> print(gi) <module 'gi' from '/usr/lib/python3/dist-packages/gi/__init__.py'>
So in my case the module gi
was installed to /usr/lib/python3/dist-packages/gi
. Assuming you have your anaconda installed in /home/kossak/anaconda3
, create a link to gi module in the proper folder:
ln -s /usr/lib/python3/dist-packages/gi /home/kossak/anaconda3/lib/python3.5/site-packages/
If you have conda virtual environment and want gi
module to be available there, the path should be a bit different. Assuming the virtual env is called TEST:
ln -s /usr/lib/python3/dist-packages/gi /home/kossak/anaconda3/envs/TEST/lib/python3.5/site-packages/
and it works:
$ python3 Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With