0

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?

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
Thrama
  • 49
  • 6
  • How do you reconcile "a Windows VM that is not connected to the Internet. I can only download packages via browser" – Mad Physicist Aug 05 '22 at 16:00
  • 2
    Pip works just fine if you give it local wheel or tar files of packages – Mad Physicist Aug 05 '22 at 16:00
  • 1
    This isn't about *running* a script, but in installing the packages it needs. If you don't have a network connection, you are going to have to download them on the host machine and install them via a shared disk (or whatever mechanism your virtualization software supports for transferring from host to guest. – chepner Aug 05 '22 at 16:01
  • You can also establish a network connection for installation, then turn it off before running the script. – chepner Aug 05 '22 at 16:01
  • 1
    Maybe this is helpful: https://stackoverflow.com/questions/7263696/how-do-i-include-3rd-party-modules-with-my-python-scripts – Barmar Aug 05 '22 at 16:02
  • @MadPhysicist Sorry for the sentence that was not very clear. I try to be more detailed: I am on a Windows VM where the proxy configurations only allow me to browse or download packages via browser. – Thrama Aug 05 '22 at 16:16
  • In that case, my answer should work for you just fine – Mad Physicist Aug 05 '22 at 17:19

1 Answers1

1

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.

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264