简体   繁体   English

如何将以非root用户身份安装在另一台服务器上的python安装重新定位到其他目录中的另一台服务器?

[英]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. 我们有两台linux服务器,一台在没有Internet访问的专用网络上。 The other is on public network which has internet access. 另一个在具有互联网访问权限的公共网络上。 Both the servers run the same RHEL-5 OS. 两台服务器运行相同的RHEL-5 OS。

On as server which has internet access, I have installed python under my home directory as non-root user. 在具有Internet访问权限的服务器上,我以非root用户身份在主目录下安装了python。 Then I used pip to install other packages, pip also resolves dependencies and install the required dependencies. 然后,我用pip安装了其他软件包,pip还解决了依赖关系并安装了所需的依赖关系。

How I can relocate this python to a server which does not have root access ? 我如何才能将此Python重新定位到没有root访问权限的服务器? 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. 由于私有服务器没有互联网访问权限,因此pip无法安装100多个模块并存在相关性。 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 ? 由于服务器运行的是同一OS版本,是否有任何简便的方法可以将安装在一台服务器上的python迁移到另一台服务器(尽管位于另一个目录中)?

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): 在第一台计算机上(具有Internet访问权限和已安装的软件包):

     mkdir /tmp/pypackages pip install -r <(pip freeze) -d /tmp/pypackages 
  2. On the second machine: 在第二台机器上:

    • Copy the packages to /tmp/pypackages 将软件包复制到/tmp/pypackages
    • Install them: 安装它们:

       cd /tmp/pypackages pip install * 

      (either as root or as a regular user). (以root或普通用户身份)。

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 . 需要注意的是,当我尝试我的机器上运行的第一个命令集,我得到了一些错误,我的是,并非所有被显示的包的事实,怪pip freeze与实际上安装了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. pip freeze的输出保存到文件并进行编辑可能会更容易。

PS python itself can also be downloaded, transferred, and installed locally by means of the system package manager. PS python本身也可以通过系统软件包管理器进行本地下载,传输和安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM