Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Python packages from local file system folder to virtualenv with pip

Tags:

python

pip

Is it possible to install packages using pip from the local filesystem?

I have run python setup.py sdist for my package, which has created the appropriate tar.gz file. This file is stored on my system at /srv/pkg/mypackage/mypackage-0.1.0.tar.gz.

Now in a virtual environment I would like to install packages either coming from pypi or from the specific local location /srv/pkg.

Is this possible?

PS I know that I can specify pip install /srv/pkg/mypackage/mypackage-0.1.0.tar.gz. That will work, but I am talking about using the /srv/pkg location as another place for pip to search if I typed pip install mypackage.

like image 907
chadgh Avatar asked Feb 22 '13 19:02

chadgh


People also ask

How do I install a Python package from a local file?

To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

Can you pip install a local package?

Install the downloaded package into a local directory : python get-pip.py --user This will install pip to your local directory (. local/bin) . Now you may navigate to this directory (cd . local/bin) and then use pip or better set your $PATH variable this directory to use pip anywhere : PATH=$PATH:~/.

Can Python packages be installed 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.


2 Answers

What about::

pip install --help ...   -e, --editable <path/url>   Install a project in editable mode (i.e. setuptools                               "develop mode") from a local project path or a VCS url. 

eg, pip install -e /srv/pkg

where /srv/pkg is the top-level directory where 'setup.py' can be found.

like image 194
kejbaly2 Avatar answered Oct 16 '22 14:10

kejbaly2


I am pretty sure that what you are looking for is called --find-links option.

You can do

pip install mypackage --no-index --find-links file:///srv/pkg/mypackage 
like image 34
Mikko Ohtamaa Avatar answered Oct 16 '22 15:10

Mikko Ohtamaa