获取ImportError:在创建虚拟环境期间无法导入名称HTTPSHandler

时间:2014-02-12 11:20:00

标签: python virtualenv

我有一个Raspberry Pi,我通过执行以下操作升级到Python 3.3.3:

sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev
wget http://www.python.org/ftp/python/3.3.3/Python-3.3.3.tar.bz2
tar jxf ./Python-3.3.3.tar.bz2
cd ./Python-3.3.3
./configure --prefix=/opt/python3.3.3
make && sudo make install

然后执行:virtualenv -p /opt/python3.3.3/bin/python3.3 python3.3.3

我收到此错误消息:

Running virtualenv with interpreter /opt/python3.3.3/bin/python3.3
Using base prefix '/opt/python3.3.3'
New python executable in python3.3.3/bin/python3.3
Also creating executable in python3.3.3/bin/python
Installing setuptools, pip...
  Complete output from command /home/pi/venv/python3.3.3/bin/python3.3 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/__init__.py", line 10, in <module>
  File "/usr/local/lib/python3.2/dist-packages/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/util.py", line 18, in <module>
  File "/usr/local/lib/python3.2/dist-packages/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/distlib/version.py", line 14, in <module>
  File "/usr/local/lib/python3.2/dist-packages/virtualenv_support/pip-1.5.1-py2.py3-none-any.whl/pip/_vendor/distlib/compat.py", line 66, in <module>
ImportError: cannot import name HTTPSHandler
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 2338, in <module>
    main()
  File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 824, in main
    symlink=options.symlink)
  File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 992, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 960, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/usr/local/lib/python3.2/dist-packages/virtualenv.py", line 902, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/pi/venv/python3.3.3/bin/python3.3 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1

1 个答案:

答案 0 :(得分:1)

在构建像Giorgio提到的2.7时,我也遇到了这个问题。 user3301335是完全正确的 - 在构建python时,有可编译的可选模块具有库依赖性。

为了节省人们挖掘评论的时间,解决方案是在您的操作系统上安装SSL开发包。 APT包被称为libssl-dev;在Red Hat上,它看起来像openssl-devel