Search code examples
pythonvirtualenvredhat

Deploy Python virtualenv on no internet machine with different system


I need to deploy python application to a no internet server.

I have created a virtual environment on my host machine which uses Ubuntu. This contains python script with a variety of non-standard libraries. I have used option --relocatable to make the links relative.

I have copied over the environment to my client machine which uses RedHat and has no access to the internet.

After activating it using source my_project/bin/activate the environment does not seem to be working - the python used is standard system one and the libraries don't work.

How can the virtual environment be deployed on a different server?

Edit: this is normally done through the creation of requirement.txt file and then using pip to install the libraries on the target machine, however in this case it's not possible as the machine is offline.


Solution

  • For anyone dealing with the same problem: The quickest way for me was to:

    1. Create a VirtualBox with the target system on the internet machine
    2. Download wheel files using pip download
    3. Migrate to the target machine
    4. Install with pip install --no-index --find-links pip_libs/ requests