سؤال

I have a pip requirements file with pinned package versions. I need to install PyPI packages on a system without a direct internet connection. How can I easily download the packages I need now, for pip installation later, without visiting each package page myself?

هل كانت مفيدة؟

المحلول

The pip documentation has a good example of fast and local installs:

$ pip install --download <DIR> -r requirements.txt
$ pip install --no-index --find-links=[file://]<DIR> -r requirements.txt

This is mostly for speed, but if you do the first step on an internet connected machine, copy the files to the other machine, then run the second step, you should be able to install all of your requirements without an internet connection.

نصائح أخرى

To add to ford's answer, in order to get around cross-platform issues one can do the following instead:

On the machine with internet access do:

$ pip install --download <DIR> -r requirements.txt
$ pip install --download <DIR> -r requirements.txt --no-use-wheel

This will download available wheels for the packages in case the wheel is cross platform, but will also download the source so the packages can be built on any platform in case the wheel doesn't work for the target system.

Then, as ford has suggested, after moving the from the machine with internet access to the other machine do:

$ pip install --no-index --find-links=[file://]<DIR> -r requirements.txt

I can't guarantee this will work in every case, but it worked for me when trying to download a package and its dependencies on a Windows machine with internet access to install on a CentOS machine without internet access. There may also be other factors to consider if using different versions of Python on each machine (in my case I had Python 3.4 on both).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top