Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install python3-gi within virtualenv?

I'm following the Python GTK+ 3 Tutorial and I'm trying to get a working install running in virtualenv. I have python3-gi installed through the Ubuntu package manager already. Things look like this:

:~$ mkvirtualenv py3 --python=/usr/bin/python3 Running virtualenv with interpreter /usr/bin/python3 Using base prefix '/usr' New python executable in py3/bin/python3 Also creating executable in py3/bin/python Installing setuptools, pip...python done. (py3):~$ python Python 3.4.0 (default, Apr 11 2014, 13:05:11)  [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named 'gi' >>>  (py3):~$ deactivate :~$ /usr/bin/python3 Python 3.4.0 (default, Apr 11 2014, 13:05:11)  [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>>  

As you can see, python3-gi is obviously not available within virtualenv but I am not sure how to install it since python3-gi is installed through my package manager and not with pip.

like image 791
Nicholas Kolatsis Avatar asked Oct 31 '14 15:10

Nicholas Kolatsis


People also ask

Can I install Python in virtualenv?

virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.

How do I install a specific version of a Python in a virtual environment?

By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag : $ virtualenv -p python3. 2 my_env Running virtualenv with interpreter /usr/local/bin/python3.

How do I add python3 to environment?

In the csh shell − type setenv PATH "$PATH:/usr/local/bin/python3" and press Enter. In the bash shell (Linux) − type export PYTHONPATH=/usr/local/bin/python3. 4 and press Enter. In the sh or ksh shell − type PATH = "$PATH:/usr/local/bin/python3" and press Enter.


1 Answers

It is now possible to resolve this using vext. Vext allows you to install packages in a virtualenv that individually access your system packages. To access gi, do the following:

pip install vext pip install vext.gi 
like image 162
lofidevops Avatar answered Sep 20 '22 07:09

lofidevops