According to this answer, apt-get
installs packages system-wide (from canonical), and only pip
can install packages into a virtualenv (from Pypi).
However, I need to install a package into a virtualenv that is only accessible via apt-get
, i.e. is not hosted by Pypi.
How do I do that?
Best Answer
Another alternative is to download the file with
apt-get download
, extract it withdpkg -x
and to move the extracted files to your virtualenv:Example:
assume this results in:
Then, use dpkg to extract the data portion of the .deb file:
In the newly created
./xyz-tmp
directory, you now have all files that would have been installed to/
(root) had you usedapt-get install
.Assume they are:
You still need to map the subdirectories (e.g.
dist-packages
vs.site-packages
), and can then move the files into your virtualenv (assuming a virtualenv/home/user/.virtualenvs/py27
):Compared to my previous answer, this approach has the advantage that you don't have to research which files got installed, because you can see them in the extraction directory. It still requires a mapping of directories between the extracted archive and the virtualenv.