python virtualenv 创建python虚拟环境时报错

windows10 + python2.7.9
在桌面创建虚拟环境的时候出现:

 C:\Users\我们都是小怪兽\Desktop>virtualenv myenv
New python executable in C:\Users\我们都是小怪兽\Desktop\myenv\Scripts\python.exe
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 9: ordinal not in range(128)
ERROR: The executable C:\Users\我们都是小怪兽\Desktop\myenv\Scripts\python.exe is not functioning
ERROR: It thinks sys.prefix is u'c:\\users\\\u6211\u4eec\u90fd\u662f\u5c0f\u602a\u517d\\desktop' (should be u'c:\\users\\\u6211\u4eec\u90fd\u662f\u5c0f\u602a\u517d\\desktop\\myenv')
ERROR: virtualenv is not compatible with this system or executable
Note: some Windows users have reported this error when they installed Python for "Only this user" or have multiple versions of Python installed. Copying the appropriate PythonXX.dll to the virtualenv Scripts/ directory may fix this problem.

除了桌面的其他目录出现这个:

 PS C:\> cd D:\Coding\python
PS D:\Coding\python> virtualenv env
New python executable in D:\Coding\python\env\Scripts\python.exe
Installing setuptools, pip, wheel...
  Complete output from command D:\Coding\python\env\Scripts\python.exe - setuptools pip wheel:
  Collecting setuptools
Exception:
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\virtualenv_support\pip-8.0.2-py2.py3-none-any.whl\pip\basecommand.py", line 209, in main
    status = self.run(options, args)
  File "c:\python27\lib\site-packages\virtualenv_support\pip-8.0.2-py2.py3-none-any.whl\pip\commands\install.py", line 299, in run
    requirement_set.prepare_files(finder)
  File "c:\python27\lib\site-packages\virtualenv_support\pip-8.0.2-py2.py3-none-any.whl\pip\req\req_set.py", line 359, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "c:\python27\lib\site-packages\virtualenv_support\pip-8.0.2-py2.py3-none-any.whl\pip\req\req_set.py", line 576, in _prepare_file
    session=self.session, hashes=hashes)
  File "c:\python27\lib\site-packages\virtualenv_support\pip-8.0.2-py2.py3-none-any.whl\pip\download.py", line 809, in unpack_url
    hashes=hashes
  File "c:\python27\lib\site-packages\virtualenv_support\pip-8.0.2-py2.py3-none-any.whl\pip\download.py", line 648, in unpack_http_url
    hashes)
  File "c:\python27\lib\site-packages\virtualenv_support\pip-8.0.2-py2.py3-none-any.whl\pip\download.py", line 868, in _download_http_url
    file_path = os.path.join(temp_dir, filename)
  File "D:\Coding\python\env\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 7: ordinal not in range(128)
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\virtualenv.py", line 711, in main
    symlink=options.symlink)
  File "c:\python27\lib\site-packages\virtualenv.py", line 944, in create_environment
    download=download,
  File "c:\python27\lib\site-packages\virtualenv.py", line 900, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "c:\python27\lib\site-packages\virtualenv.py", line 795, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command D:\Coding\python\env\Scripts\python.exe - setuptools pip wheel failed with error code 2

想不通是什么问题,求解。

补充:如果加上 --no setuptools就可以了

 PS D:\Coding\python> virtualenv myenv --no-setuptools
New python executable in D:\Coding\python\myenv\Scripts\python.exe
Installing pip, wheel...done.

3个回答

可能是路径中含有中文,你到一个没有中文的路径下测试看看

hijack00
hijack00 回复Coastharukun: 你贴出来的错误信息里面有ERROR: virtualenv is not compatible with this system or executable Note: some Windows users have reported this error when they installed Python for "Only this user" or have multiple versions of Python installed. Copying the appropriate PythonXX.dll to the virtualenv Scripts/ directory may fix this problem.,意思是说你的virtualenv和你的系统不兼容。可能的原因是安装python时选择了"Only this user",或者是安装了多个版本的Python。尝试将正确版本的pythonxx.dll文件复制到virtualenv的Scripts/目录下以修复这个问题。
接近 4 年之前 回复
Coastharukun
Coastharukun Hmm, 还是这个错误。
接近 4 年之前 回复
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 7: ordinal not in range(128)

http://blog.csdn.net/marksinoberg/article/details/52254401

可能是网络问题。

我也遇到过这个问题,我这里的报错信息是在这句话后面出现的:
Collecting setuptools
Downloading setuptools-38.5.1-py2.py3-none-any.whl (489kB)

报错信息的第一条是酱紫的:
Traceback (most recent call last):
File "/****/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/response.py", line 226, in _error_catcher

所以我猜测是网络问题,因为我开着vpn。

然后,我把vpn关了,重新建虚拟环境,就成功了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问