Coastharukun
Coastharukun
采纳率0%
2016-08-25 03:24 阅读 26.4k

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 2016-08-25 03:52

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

    点赞 3 评论 复制链接分享
  • Marksinoberg 泰 戈 尔 2016-08-25 12:58
     UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 7: ordinal not in range(128)
    

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

    点赞 1 评论 复制链接分享
  • zwm1210500550 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关了,重新建虚拟环境,就成功了。

    点赞 评论 复制链接分享

相关推荐