Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install packages using pip according to the requirements.txt file from a local directory?

Here is the problem:

I have a requirements.txt file that looks like:

BeautifulSoup==3.2.0 Django==1.3 Fabric==1.2.0 Jinja2==2.5.5 PyYAML==3.09 Pygments==1.4 SQLAlchemy==0.7.1 South==0.7.3 amqplib==0.6.1 anyjson==0.3 ... 

I have a local archive directory containing all the packages + others.

I have created a new virtualenv with

bin/virtualenv testing 

Upon activating it, I tried to install the packages according to requirements.txt from the local archive directory.

source bin/activate pip install -r /path/to/requirements.txt -f file:///path/to/archive/ 

I got some output that seems to indicate that the installation is fine:

Downloading/unpacking Fabric==1.2.0 (from -r ../testing/requirements.txt (line 3))   Running setup.py egg_info for package Fabric     warning: no previously-included files matching '*' found under directory 'docs/_build'     warning: no files found matching 'fabfile.py' Downloading/unpacking South==0.7.3 (from -r ../testing/requirements.txt (line 8))   Running setup.py egg_info for package South .... 

But a later check revealed that none of the packages are installed properly. I cannot import the packages, and none are found in the site-packages directory of my virtualenv. So what went wrong?

like image 541
kakarukeys Avatar asked Aug 29 '11 03:08

kakarukeys


People also ask

How do I install packages in requirements text?

Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file.

Can pip install from local directory?

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:~/.

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.


1 Answers

This works for everyone:

pip install -r /path/to/requirements.txt 
like image 149
Mike Lyons Avatar answered Oct 25 '22 03:10

Mike Lyons