2016-01-24 185 views
7

我在ubuntu上安裝了virtualenv。但是,當我嘗試創建virtualenv時,出現錯誤。我的Zenv文件夾不包含「激活」。我該如何解決它?我會經常這樣做。這是我第一次得到這個錯誤。virtualenv ImportError:沒有名爲urllib3的模塊

[email protected]:~$ virtualenv Zenv 
New python executable in /home/ubuntu/Zenv/bin/python 
Installing setuptools, pip, wheel... 
    Complete output from command /home/ubuntu/Zenv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel: 
    Traceback (most recent call last): 
    File "<string>", line 1, in <module> 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/__init__.py", line 15, in <module> 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/vcs/mercurial.py", line 9, in <module> 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/download.py", line 38, in <module> 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/requests/__init__.py", line 58, in <module> 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/requests/utils.py", line 26, in <module> 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/requests/compat.py", line 7, in <module> 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/requests/packages/__init__.py", line 29, in <module> 
ImportError: No module named urllib3 
---------------------------------------- 
...Installing setuptools, pip, wheel...done. 
Traceback (most recent call last): 
    File "/home/ubuntu/anaconda/bin/virtualenv", line 11, in <module> 
    sys.exit(main()) 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv.py", line 703, in main 
    symlink=options.symlink) 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv.py", line 904, in create_environment 
    download=download, 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv.py", line 861, in install_wheel 
    call_subprocess(cmd, show_stdout=False, extra_env=env) 
    File "/home/ubuntu/anaconda/lib/python2.7/site-packages/virtualenv.py", line 781, in call_subprocess 
    % (cmd_desc, proc.returncode)) 
OSError: Command /home/ubuntu/Zenv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1 

回答

6

就我而言,我從我的anaconda那裏得到的python版本干擾了我在/ usr/bin中的python。這爲我工作:

virtualenv my-virtualenv -p /usr/bin/python 
0

這解決了這個問題對我來說

pip install -i https://pypi.anaconda.org/pypi/simple urllib3 
0
wget https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz#md5=fcaab1c5385c57deeb7053d3d7d81d59 
tar xvf urllib3-1.16.tar.gz && cd urllib3-1.16/ 
python setup.py install 
1

'的virtualenv VENV' 可以使用Python的蟒蛇,這可能會導致問題。

'的virtualenv VENV -p在/ usr/bin中/ Python的' 可能會遇到這個問題,但它使用在你的系統默認的Python,而不是Python的蟒蛇。

所以你可以使用「PIP安裝的virtualenv」您安裝蟒蛇面前,不要在蟒蛇不安裝的virtualenv。

相關問題