how to download pip dependencies locally?
Solution 1
You can fetch all dependencies with the following command (an Internet connection is of course required)
pip download -r requirements.txt
Then, you can install offline those dependencies with the following command
pip install -r requirements.txt --no-index --find-links file:///tmp/packages
--no-index
: Ignore package index (only looking at--find-links
URLs instead).
-f, --find-links <URL>
: If a URL or path to an html file, then parse for links to archives. If a local path orfile://
URL that's a directory, then look for archives in the directory listing.
This answer is taken from this post
Solution 2
Look at: http://docs.cloudfoundry.org/buildpacks/python/index.html#vendor-app-dependencies
tl;dr pip install --download vendor -r requirements.txt
Just use pip to install on the dev box and then check that in.
Related videos on Youtube
Anthony
Updated on September 14, 2022Comments
-
Anthony over 1 year
I am running my python application that has
requirements.txt
file which contains various dependencies. I am deploying this application in a Pivotal Cloud Foundry environment. However, the environment I am deploying in it airgapped. Therefore I can't seem to get the dependencies.The Git repo for python CF buildpack suggests that if an application has a
vendor
directory then it might get the dependencies from there: https://github.com/cloudfoundry/python-buildpack/blob/master/bin/steps/pip-install#L18My question is, how can I download the dependencies mentioned in my
requirements.txt
file locally into avendor
folder? -
Anthony almost 7 yearsSo my
requirements.txt
hasnumpy
in it. I run the above command using docker container for CF:docker run -v $PWD:/myapp -it cloudfoundry/cflinuxfs2 bash
then I installpip
in that and then runpip install --download vendor -r requirements.txt
. This downloads the files in myvendor
directory. and one of the files is callednumpy-1.13.0-cp27-cp27mu-manylinux1_x86_64.whl
. However, when I try to push my application, I get an errornumpy-1.13.0-cp27-cp27mu-manylinux1_x86_64
-
jonrsharpe almost 7 yearsIf you find a duplicate, please close as such rather than copying over the answer.