Search code examples
pythonpip

Run a Python script on a host without Internet connection


I read all the proposed related questions but didn't find an answer to my case.

As for the title, I need to run a Python script (e.i. not an executable created with pyInstall) on a Windows VM that is not connected to the Internet. I can only download packages via browser.

Install Python is not a problem, but pip doesn't work, so I have the libraries issue.

Do you have any suggestions?


Solution

  • If you go to PyPi, where pip searches for packages, and find a package you are interested in, you can click on "Download Files" on the left panel. Using numpy as an example: https://pypi.org/project/numpy/#files

    enter image description here

    You can manually download the files that you want for each package and install them directly with pip. Keep in mind that the first couple of rounds will likely involve error messages telling you that there are missing dependencies. You will have to go back to PyPi and get those dependencies as well, until everything installs correctly.

    You may want to check the following question for information regarding manual dependency management: How to extract dependencies from a PyPi package.