【发布时间】:2017-10-09 16:53:32
【问题描述】:
目标:在我的 RHEL 服务器上安装 python 2.7.14 和 python 3.6,并使用 pip2/pip3 来管理两者。
注意:虽然这个服务器没有网络连接,但我可以单独下载并上传到这个服务器。
我最近在 VM 上安装了 RHEL 7.2,默认情况下会安装 python 2.7.5。 我决定通过并行安装 2.7.14 来升级它(使用 make altinstall 方法并保持现有的 2.7.5 不变)。还安装了 python 3.6,因为我计划将来将所有现有的 python 代码移植到它。
当我尝试为 Python 2.7.14 或任何库安装 pip 时出现问题(稍后您会看到)。
我首先做了一个简单的 pip 安装:
[root@VMW01 bin]# easy_install pip
Searching for pip
Best match: pip 9.0.1
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Installing pip3.5 script to /usr/local/bin
Using /usr/local/lib/python3.6/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
这将为 python 2.7.5 和 3.6 安装 pip,但不为 python 2.7.14 安装。
接下来,我下载了get-pip.py:
这对于 python 2.7.5 安装得很好,但对于 python 2.7.14 不是:
[root@VMW01 pshah]# python get-pip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 978kB/s
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
100% |████████████████████████████████| 51kB 9.2MB/s
Installing collected packages: pip, wheel
Successfully installed pip-9.0.1 wheel-0.30.0
[root@VMW01 pshah]# /usr/local/bin/python2.7 get-pip.py
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
这似乎缺少 SSL 库。
首先,我确实使用 yum 安装了它:
[root@VMW01 pshah]# yum install openssl
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
[root@VMW01 pshah]# yum install openssl-devel
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package 1:openssl-devel-1.0.1e-42.el7_1.9.x86_64 already installed and latest version
Nothing to do
其次,这似乎存在于 python 2.7.5
[root@VMW01 pshah]# python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
我是不是太过分了?我应该选择默认安装的 2.7.5 和 python 3.6 吗?
我知道 virtualenv 在这里可能是一个解决方案,但我不确定如何使它与 Apache 执行 python 脚本一起工作。
谢谢。
【问题讨论】:
标签: python-2.7 python-3.x pip