How to install gi module for anaconda python3?

conda install gtk3
namespace gtk not available
no module named gi windows
conda install pygtk
install python-gi ubuntu
python3 gi centos
pygtk python 3 install
no module named gi mac

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

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
>>>

How to install gi module for anaconda python3?, Here's how you do it: (example for Linux Mint and python3). First install the gi module using your distribution package manager. For Linux Mint, this will be: I also faced this issue while trying to import gi from miniconda python3.7 and fixed it by doing the following: First, create a symlink to gi module in your system python.

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

python - How to install gi for anaconda python3.6, 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  Apparently Python 3.5 isn't supported yet as we can read this in the readme.txt: PyGI 3.18.2 AIO rev6 for python 2.7, 3.1, 3.2, 3.3 and 3.4 (32bit/64bit) and Python 3.5 port is WIP. – Creak Jul 9 '16 at 4:28

If you want to perform a proper install (without soft linking) inside a Linux anaconda environment. Keep in mind that the errors may vary if you have not installed gcc previously (I assumed it was installed by default when I posted, however not everyone does so). Install it if you don't know very well what you're doing to avoid missunderstandings

  1. Create or open your conda environment.

  2. Attemp to install pygobject (don't worry, it will most likely throw an error):

    pip install pygobject
    

    In linux, it will promp the usual installation progress followed by an error:

    (...) Please, try executing the following in your system: sudo apt install libgirepository1.0-dev

    Depending on your operation sistem or installed dependencies, the command name or package name may vary. Just follow the instructions and allow the system to install your packets. This step doesn't change anything, is just to give you the precise info of the package you need on your system. If you run this on Windows, it will ask you to install a specific version of Visual Studio. If you are in Windows, download the required Visual Studio from MS website, install it, reboot your computer and go to step 5 (in my case I never needed step 4 in windows, however, I'm not a MS expert.

  3. Close your conda environment

    conda deactivate
    
  4. Next you need to install pygobject from conda-forge repository in your conda environment. You can add the repo to your favourite conda package manager or simply run the following command as root (it is important to be root). I did it outside the project, but you may do it inside:

    conda install -c conda-forge pygobject
    

    In my case conda was not in the path. I had is installed in:

    /opt/anaconda3/bin/
    

    You can run the following command from your normal user to find out where conda is:

    which conda
    
  5. Open the conda environment

    source activate <your env name>
    

    or the corresponding anaconda activate syntax (I never use it so I cant remember precisely)

  6. Repeat the first step and now the installation wont fail:

    pip install pygobject
    

    OR if you specifically want to install gi you can run:

    pip install pgi
    

    the correct package is "pgi" NOT "gi"

As gi is a dependency of pygobject, everything will get properly installed. You can check it by running

python
>>> import gi

You may find the following usefull for Windows, although you may need to work it out a bit: GStreammer python bindings on Windows

Pygobject :: Anaconda Cloud, conda install. linux-64 v3.30.5; win-64 v3.30.5; osx-64 v3.30.5. To install this package with conda run one of the following: conda install -c 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:

for me

conda install -c pkgw/label/superseded gtk3

worked

How to install gi module for anaconda python3?, 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  Starting with Python 3.4, it defaults to installing pip into all created virtual environments. virtualenv is a third party alternative (and predecessor) to venv . It allows virtual environments to be used on versions of Python prior to 3.4, which either don’t provide venv at all, or aren’t able to automatically install pip into created environments.

Getting Started, Installing the system provided PyGObject: Open a terminal. Execute sudo apt install python3-gi python3-gi-cairo gir1. 2-gtk-3.0. Change the directory to where your hello.py script can be found (e.g. cd Desktop ) Run python3 hello.py. I have just installed Anaconda for Python 3 and then installed PySide by sudo apt-get install python3-pyside Then I tried to use it throw Anaconda's version of python and typed import PySide bu

How to install gi module for anaconda python3?, 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  how to install packages in anacoda 3 in python. if you have Anaconda 2 and 3 installed on your computer, replace pip with pip3 conda install pip (if you don't have pip installed, install it using

PyGtk3, No Module Named gi, on python3.5 on Windows, 4 and installed pygobject3.18.2 on python3.5 64 bit but after installation, when I import gi module, python give no module named error! please 

Comments
  • Hello. I've posted a new solution which doesn't involve soft-linking. Could you check if it looks usefull to you?
  • on Ubuntu 18.04. pydobject ValueError: Namespace GdkX11 not available
  • This is the correct answer to the original question :)