trouble with creating a virtual environment in Windows 8, python 3.3

让人想犯罪 __ 提交于 2019-12-07 01:30:43

问题


I'm trying to create a virtual environment in Python, but I always get an error no matter how many times I re-install python-setuptools and pip.

My computer is running Windows 8, and I'm using Python 3.3.

E:\Documents\proj>virtualenv venv --distribute
Using base prefix 'c:\\Python33'
New python executable in venv\Scripts\python.exe
Installing setuptools, pip...
  Complete output from command E:\Documents\proj\venv\Scripts\python.exe -c "imp
ort sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\pip-1.5-py2.py3-none-any.whl\pip\__init__.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\pip-1.5-py2.py3-none-any.whl\pip\log.py", line 8, in <module>
  File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 2696, in <modul
e>
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 429, in __init_
_
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 443, in add_ent
ry
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1722, in find_i
n_zip
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1298, in has_me
tadata
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1614, in _has
  File "c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv_suppo
rt\setuptools-2.0.2-py2.py3-none-any.whl\pkg_resources.py", line 1488, in _zipin
fo_name
AssertionError: c:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\EGG-INFO
\PKG-INFO is not a subpath of c:\Python33\lib\site-packages\virtualenv-1.11-py3.
3.egg\virtualenv_support\setuptools-2.0.2-py2.py3-none-any.whl\
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "C:\Python33\Scripts\virtualenv-script.py", line 9, in <module>
    load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
  File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 820, in main
    symlink=options.symlink)
  File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 988, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 956, in install_wheel
    'PIP_NO_INDEX': '1'
  File "C:\Python33\lib\site-packages\virtualenv-1.11-py3.3.egg\virtualenv.py",
line 898, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command E:\Documents\proj\venv\Scripts\python.exe -c "import sys, pip;
pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1

回答1:


I've found a solution to this problem. Only the latest virtualenv (v1.11) which was released just a few days ago has this problem. Remove the egg from your site-packages folder and install the previous version via easy_install virtualenv==1.10.1, virtualenv will work fine.




回答2:


I install virtulaenvwrapper-win and upgrade my virtualenv version to latest (1.11.5) with command:

pip install virtualenv --upgrade

If i write:

mkvirtualenv demo --system-site-packages --python=C:\Python34\python.exe

i see:

python.exe: can't open file 'C:\Python34\Scripts\virtualenv-script.py': [Errno 2] No such file or directory

Solution - using virtualenv, non virtualenvwrapper:

cd C:\www\virtualenvs
virtualenv demo --system-site-packages --python=C:\Python34\python.exe

Now i use workon only for activate/deactivate virtual environment. System: Windows 8.1 x64




回答3:


With virtualenvwraper==4.7.1 (and probably above), one could just edit mkvirtualenv.bat like this:

uncomment line 48 (remove REM):

virtualenv.exe %*

comment line 49 (add REM)

REM python.exe "%PYHOME%\Scripts\virtualenv-script.py" %ARGS%


来源:https://stackoverflow.com/questions/20925329/trouble-with-creating-a-virtual-environment-in-windows-8-python-3-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!