gpt4 book ai didi

python - 导入错误 : cannot import name HTTPSHandler

转载 作者:太空宇宙 更新时间:2023-11-03 12:04:19 25 4
gpt4 key购买 nike

刚刚安装了 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

最佳答案

我正在使用 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

重新编译

关于python - 导入错误 : cannot import name HTTPSHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36902306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com