刚刚安装了pip,但我无法导入它。操作系统是RedHat企业,我也安装了最新的openssl(从源代码编译)。
$ easy_install pip
Searching for pip
Best match: pip 8.1.1
Adding pip 8.1.1 to easy-install.pth file
Installing pip script to XXX/local/bin
Installing pip3.5 script to XXX/local/bin
Installing pip3 script to XXX/local/bin
Using XXX/local/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
$ python
Python 2.7 (r27:82500, Apr 27 2016, 15:32:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "XXX/local/lib/python2.7/site-packages/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "XXX/local/lib/python2.7/site-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "XXX/local/lib/python2.7/site-packages/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "XXX/local/lib/python2.7/site-packages/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "XXX/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "XXX/local/lib/python2.7/site-packages/pip/_vendor/distlib/compat.py", line 31, in <module>
from urllib2 import (Request, urlopen, URLError, HTTPError,
ImportError: cannot import name HTTPSHandler
我知道我必须以与python一起工作的方式配置我的openssl(根据this)。这是我在编译之前配置openssl的方式:
# openssl-1.0.2g
./config --prefix=XXX/local \
--openssldir=XXX/local/etc/ssl \
--libdir=lib \
shared \
zlib-dynamic \
-LXXX/local/lib \
-IXXX/local/include
Python版本是2.7
答案 0 :(得分:0)
我正在使用Centos并面临这个问题。
解决的最佳方法是:
yum install openssl openssl-devel -y
yum install krb5-devel -y
尝试以下两个选项之一:
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
OR
重新编译