0

I'm working on a Linux machine without (direct) Internet access. I want to pip install foo for some pypi package foo, but - obviously, that won't work. I have, of course, other machines which are connected the Internet.

How would I go about determining what files need to be downloaded, downloading them and installing them once they're on the isolated machine?

Notes:

  • I'd rather get a Python-version-independent answer, but if it is version-dependent, let's assume Python 3.6 or later.
  • This question sounds the same, but it's actually about installing pip istelf.

1 Answer 1

1

You can ask pip to download a .whl wheel file (and its dependency wheel files) instead of installing it:

pip download foo

(on an Internet-connected system, replacing foo with your actual package as appropriate).

Then copy the downloaded files to the off-line system, and install with

pip install --no-index --find-links . foo

You can replace . with the path to the directory with the wheel(s), and foo with the package name.

In both cases, foo can be replaced with -r /path/to/requirements.txt. pip download supports a variety of options to specify the version of Python to download for, the architecture etc.

2
  • Will the download command acquire all dependencies (other than pip itself)? Won't it go by the dependencies on the system with the access to the internet?
    – einpoklum
    Apr 2 at 19:26
  • 1
    It’s not clear from the documentation, but in my tests it downloads everything, ignoring installed dependencies. For example, in a clean venv, pip install idna installs idna-3.6, and a subsequent pip download sphinx downloads the idna-3.6 wheel even though the module is installed. Apr 2 at 19:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .