Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a globally installed package to virtualenv folder

So I have a virtualenv folder called venv for my python project.

I can run:

venv/bin/pip install -r requirements.txt 

Which installs all requirements I need for the project except one, M2Crypto. The only way to install it is through apt-get:

apt-get install python-m2crypto 

How can I then add this package installed through apt to venv folder?

like image 398
Richard Knop Avatar asked Dec 21 '12 14:12

Richard Knop


People also ask

Where are packages installed in virtualenv?

Similar to your system's Python installation, the packages are stored inside lib/python2. */site-packages/ directory.

Can I install packages in virtual environment?

As long as your virtual environment is activated pip will install packages into that specific environment and you'll be able to import and use packages in your Python application.

Where is the virtualenv folder?

virtualenvs folder in the home directory. You can either source the virtualenvwrapper commands to run from the terminal or add the virtualenvwrapper commands to the . bashrc . Now the commands will be accessible in the current terminal by pressing the Tab key.


1 Answers

--system-site-packages 

gives access to the global site-packages modules to the virtual environment.

you could do:

$ sudo apt-get install python-m2crypto $ virtualenv env --system-site-packages 

... and you would then have access to m2crypto (along with all other system-wide installed packages) inside your virtualenv.

like image 57
Corey Goldberg Avatar answered Sep 21 '22 08:09

Corey Goldberg