user1149518 user1149518 - 1 month ago 9
Python Question

How to relocate python installation installed as non-root user on another server to another server in different directory?

We have two linux servers, one is on private network which does not have internet access. The other is on public network which has internet access. Both the servers run the same RHEL-5 OS.

On as server which has internet access, I have installed python under my home directory as non-root user. Then I used pip to install other packages, pip also resolves dependencies and install the required dependencies.

How I can relocate this python to a server which does not have root access ? Also I want to relocate it as root under different directory ?

Why I want to do this ? Since the private server does not have internet access pip won't work for installing 100s of modules and there dependencies. Since the servers are running the same OS release, is there any easy way to relocate python installed on one server to another server though in a different directory ?


If possible, I'd try to go through the front door and actually install the packages on the other server. Cloning of all packages should in principle be equivalent to the following:

  1. On the first machine (with Internet access and installed packages):

    mkdir /tmp/pypackages
    pip install -r <(pip freeze) -d /tmp/pypackages
  2. On the second machine:

    • Copy the packages to /tmp/pypackages
    • Install them:

      cd /tmp/pypackages
      pip install *

      (either as root or as a regular user).

Note that when I try to run the first set of commands on my machine, I get some errors which I blame on the fact that not all of the packages shown by pip freeze were actually installed with pip. You may need to filter that list as well. It'll probably be easier to save the output of pip freeze to a file and edit it.

P.S. python itself can also be downloaded, transferred, and installed locally by means of the system package manager.