6

We have a python/django based web application, many components of which are installed using pip. So I would like to ask if there is a way to save or download and save the particular python packages that we are having pip install (example: pip install django==1.5.1). We would like to have in the end a collection of the packages in the versions known to be working and with which the app was developed locally. Any and all advice will be appreciated.

Gary Ridley
  • 317
  • 1
  • 4
  • 8
  • Maybe this [question](http://stackoverflow.com/questions/7300321/how-to-use-pythons-pip-to-download-and-keep-the-zipped-files-for-a-package) is helpful for you. – atupal Dec 17 '13 at 00:38

3 Answers3

18

If I understood your question right, you can pip freeze > requirements.txt, this command will add all the libraries you have used/"downloaded" for your app in the file requirements.txt(in case it exists the file be overwritten). This command allows you to later do pip install -r requirements.txt. However, be aware that your Django project must be running in a virtual environment, otherwise the install command will attempt to install all the python packages in your development machine.

The freeze command will allow you to have the current version of the app so upon installation will attempt to install that same version. Your requirements file will look something like:

Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
gunicorn==0.14.2
requests==0.11.1

Your packages are installed (if using virtualenv) at: ../<your project>/<your virtual env>/<lib>/<python version>/<site-packages>/

As for downloading you can use pip install --download command as @atupal suggested in his response, however think if this is really needed you can also fork those libraries on github to accomplish the same.

Here is a good source of information on how this works: http://www.pip-installer.org/en/latest/cookbook.html

lv10
  • 1,469
  • 7
  • 25
  • 46
10

Maybe what you want is:

Download the packages:

pip install --download /path/to/download/to packagename

OR

pip install --download=/path/to/packages/downloaded -r requirements.txt

install all of those libraries just downloaded:

pip install --no-index --find-links="/path/to/downloaded/dependencies" packagename

OR

pip install --no-index --find-links="/path/to/downloaded/packages" -r requirements.txt

Shamelessly stolen from this question

Community
  • 1
  • 1
atupal
  • 16,404
  • 5
  • 31
  • 42
0

Create a requirements.txt file.

Put:

django==1.5.1

in the first line.

Then run pip install -r requirements.txt

Then you can complete that file...

François Constant
  • 5,531
  • 1
  • 33
  • 39