How I can make apt-get install to my virtualenv?

Александр Кривошеев picture Александр Кривошеев · Jul 11, 2012 · Viewed 25.6k times · Source

It it's possible, of course.

For example - I can download python-dbus like this: $ sudo apt-get download python-dbus

But what I should to do next, with this .deb package in my current virtualenv?

Answer

MrColes picture MrColes · Dec 4, 2012

If you really need to do it this way, you can just copy the files that get installed globally directly into your virtualenv. For example I couldn't get pycurl working since the required libraries weren't installing, but apt-get install python-pycurl did. So I did the following:

sudo apt-get install python-pycurl
cp /usr/lib/python2.7/dist-packages/pycurl* ~/.virtualenvs/myenv/lib/python2.7/site-packages/

The install said it was adding it to /usr/lib/python2.7. So I looked in that directory for a site-packages or dist-packages with pycurl, after looking at the files I copied them into my virtualenv. You'd have to also copy any executables from bin into your virtualenv's bin directory.

Also, running a pip install -r requirements.txt successfully found pycurl in there and just skipped over it as if I had installed it via pip.