0

I am working in automation, my team has new Virtual Machines to use. however these Windows VMs come vanilla (no python, no visual c++). The current systems and code use python 2.7.10 ( dont ask why :( ). My task is to deploy the automation code on the new VMs which usually is straight forward, but these new VMs do not have internet access (but have access to SFTP WINSCP). I need to somehow transfer python 2.7.10 and all the dependencies i need such as pandas, numpy etc to the new system. Does anyone have any ideas.

What ive tried so far: Zipping up the Python directory and downloading it into the new VM (didnt work due to site_packages not being installed)

Installing Python 2.7.10 on new VM and manually download and transfer tar.gz files to the new VM and install them manually (didnt work due to constant errors)

Pip and anaconda cant be used due to no internet access

Remember im using Python 2.7.10 and pip version 7.0.3 on the current systems

  • 1
    If you weren't on Windows, this is a job that [Nix](https://nixos.org) does well (as it has a ".nar" packaging/serialization format that anything it builds can be exported to or restored from). Windows makes this a different problem than it would be anywhere else, so it might be worth mentioning in the title. – Charles Duffy May 16 '23 at 13:54
  • Literally everything is stacked against me xD and sure i have changed the title – CaffeineAndCode May 16 '23 at 13:59
  • I don't want to be the person to suggest the first result after a quick Google Search, but you did not list that you've tried it. IBM has [thorough instructions](https://www.ibm.com/docs/en/siffs/2.0.3?topic=python-installing-packages-offline-mode), but it might not apply to your specific needs. Maybe it could be used as a reference. (Edit: This is specifically Python 3.5, but I suspect you could just substitute it for your required version.) – SanguineL May 16 '23 at 14:09
  • have you tried using venv? I.e. 1st Create a venv on your online machine and make sure your code runs smoothly, 2nd install same python version on VM. 3rd Copy venv from online machine to offline machine (use same location, might be beneficial). You could even use `conda` and `conda pack/unpack` for this – FlyingTeller May 16 '23 at 14:29
  • I will keep it in mind. Im planning to upgrade all the code to Python3 soon so will look into it. Thank you – CaffeineAndCode May 17 '23 at 12:40

1 Answers1

1

From https://www.python.org/downloads/release/python-2710/ download 32-bit installer (the last one — Windows x86 MSI installer). Copy it to a VM. Inside the VM run a cmd.exe terminal and run in it msiexec /i python-2.7.10.msi to install Python.

From https://bootstrap.pypa.io/pip/2.7/ download get-pip.py; copy it to the VM. Inside a terminal in the VM run python.exe get-pip.py --no-index --upgrade. This installs/upgrades pip, setuptools and wheel.

With this pip you can install almost any package. See https://stackoverflow.com/a/14447068/7976758 . In a VM with w32 (it must be the same Python version, the same OS and the same processor architecture) that has access to internet do

pip download [-r requirements.txt] # or just list packages

Copy the downloaded packages to an offline VM and run

pip install --no-index --find-links /path/to/download/dir/ [-r requirements.txt] # or list of packages
phd
  • 82,685
  • 13
  • 120
  • 165
  • I finally found a solution. Turns out one of the engineers on another team had a Wheelhouse.zip file with all the dependencies in .whl format. I downloaded it on the target system and ran pip install [package-name].whl for all the packages. Now it is working fine. Thanks for the recommendation. – CaffeineAndCode May 17 '23 at 12:40