使用python 2.7.9安装pip时出现HTTPSHandler错误

时间:2015-08-17 15:48:42

标签: python installation openssl pip virtualenv

您好我正在尝试使用python 2.7.9安装pip,但一直遇到以下错误。我想创建python虚拟环境。

 python get-pip.py

        Traceback (most recent call last):
          File "get-pip.py", line 17767, in <module>
            main()
          File "get-pip.py", line 162, in main
            bootstrap(tmpdir=tmpdir)
          File "get-pip.py", line 82, in bootstrap
            import pip
          File "/tmp/tmp_Tfw2V/pip.zip/pip/__init__.py", line 15, in <module>
          File "/tmp/tmp_Tfw2V/pip.zip/pip/vcs/subversion.py", line 9, in <module>
          File "/tmp/tmp_Tfw2V/pip.zip/pip/index.py", line 30, in <module>
          File "/tmp/tmp_Tfw2V/pip.zip/pip/wheel.py", line 35, in <module>
          File "/tmp/tmp_Tfw2V/pip.zip/pip/_vendor/distlib/scripts.py", line 14, in <module>
          File "/tmp/tmp_Tfw2V/pip.zip/pip/_vendor/distlib/compat.py", line 31, in <module>

   ImportError: cannot import name HTTPSHandler

我想这与openssl库有关。由于我没有sudo访问权限,我想从源代码将其安装在主文件夹中。知道怎么做吗?

2 个答案:

答案 0 :(得分:11)

确保在构建Python 2.7之前安装了openssl和openssl-devel

 yum install openssl openssl-devel

apt-get install openssl openssl-devel

或(对于Debian):

apt-get install libssl-dev

重建Python

cd ~
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar xzf Python-2.7.9.tgz
cd Python-2.7.9
./configure
make install

然后python get-pip.py应该有效。

答案 1 :(得分:0)

安装openssl098e为我解决了这个问题。