Coastharukun 2016-08-25 03:24 采纳率: 0%
浏览 28942

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条回答 默认 最新

  • zwm1210500550 2018-02-06 16:07
    关注

    可能是网络问题。

    我也遇到过这个问题,我这里的报错信息是在这句话后面出现的:
    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关了,重新建虚拟环境,就成功了。

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料