Virtualenv: 路径中非ASCII汽车的问题

创建于 2013-07-29  ·  20评论  ·  资料来源: pypa/virtualenv

我不知道这是否与#186有关,但是在Windows 8上全新安装python时,在路径C:\ Users \ oncleben \ Dropbox \ Developement \fraisDeSanté中使用virtualenv时出现以下错误

C:\Users\oncleben\Dropbox\Developement\fraisDeSanté> virtualenv ENV
New python executable in ENV\Scripts\python.exe
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 50: ordinal not in range(128)
ERROR: The executable ENV\Scripts\python.exe is not functioning
ERROR: It thinks sys.prefix is u'c:\\users\\oncleben\\dropbox\\developement\\fraisdesant\xe9' (should be u'c:\\users\\on
cleben\\dropbox\\developement\\fraisdesant\xe9\\env')
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 versi
ons of Python installed. Copying the appropriate PythonXX.dll to the virtualenv Scripts/ directory may fix this problem.

python v2.7.5
点列表
鼻子(1.3.0)
点(1.4)
脚手架(0.1.3)
setuptools(0.9.7)
virtualenv(1.10)

编辑:

bug help-wanted

最有用的评论

现在,此问题已得到解决,只要文件系统编解码器可以处理它,我们也将处理它。在谈论utf-8。

所有20条评论

你好,
在这里得到了完全相同的问题:
python v2.7.5
Win7 64位
可以随意复制

看起来像#453

在带有Python v2.7.2的Mac OS X 10.8.4上也会发生此问题:

New python executable in venv/bin/python
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 16: ordinal not in range(128)
ERROR: The executable venv/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/Users/RSChiang/\u539f\u59cb\u78bc/repo' (should be u'/Users/RSChiang/\u539f\u59cb\u78bc/repo/venv')
ERROR: virtualenv is not compatible with this system or executable

拉取请求#187提到了有关FS编码的某些内容与默认编码不同。 大概系统配置会解决吗?

atykhonov的修复程序对我有用。

磕碰。 任何进展? @atykhonov如何作为请求请求发送补丁?

同上。 在Linux上也会出现问题,这里带有中文字符:

$ virtualenv /tmp/中文
New python executable in /tmp/中文/bin/python
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 5: ordinal not in range(128)
ERROR: The executable /tmp/中文/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/home/vinay/projects/scratch' (should be u'/tmp/\u4e2d\u6587')
ERROR: virtualenv is not compatible with this system or executable
vinay<strong i="6">@ubuntu</strong>:~/projects/scratch$ virtualenv --version
13.1.2
vinay<strong i="7">@ubuntu</strong>:~/projects/scratch$ /tmp/中文/bin/python
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

我有一个针对该问题的WIP补丁,虽然在修复https://bitbucket.org/pypa/distlib/pull-requests/27中的错误之前无法完成操作。

@ yan12125-我不确定您的PR是否正确,请参阅我的评论。 另外,不清楚上面的控制台转储是否与distlib问题有关-它似乎是virtualenv的另一个错误,在测试venv是否正确创建时被调用。

有许多请求请求试图解决此问题:

  • #900(#875):由我打开,所有测试均通过
  • #902(#894):由@aodag打开
  • #907(#453):由@magres打开
  • #908(#492):由@atykhonov打开
  • #912(#630):由@dholth打开

我想像Appveyor这样的Windows测试环境也是必要的。 pypa / pip已经在使用它

FI,我在Debian GNU / Linux 9.2,Python 2.7.14上遇到了相同的错误。

% pwd
/home/tiger-222/Téléchargements

Python 2:

% python2 -m pip install --user --upgrade virtualenv
Collecting virtualenv
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0

% python2 -m virtualenv test-python2   
New python executable in /home/tiger-222/Téléchargements/test-python2/bin/python2
Also creating executable in /home/tiger-222/Téléchargements/test-python2/bin/python
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 17: ordinal not in range(128)
ERROR: The executable /home/tiger-222/Téléchargements/test-python2/bin/python2 is not functioning
ERROR: It thinks sys.prefix is u'/home/tiger-222/T\xe9l\xe9chargements' (should be u'/home/tiger-222/T\xe9l\xe9chargements/test-python2')
ERROR: virtualenv is not compatible with this system or executable

Python 3:

% python3 -m pip install --user --upgrade virtualenv
Collecting virtualenv
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0

% python3 -m virtualenv test-python3
Using base prefix '/usr'
New python executable in /home/tiger-222/Téléchargements/test-python3/bin/python3
Also creating executable in /home/tiger-222/Téléchargements/test-python3/bin/python
Installing setuptools, pip, wheel...done.

无论其值多少,我都可以在Windows 7,Python 3.6.4,virtualenv 15.1.0上重现此问题,当使用用户名以$开头的用户帐户时。

PS C:\Users\$scuthbertson\Desktop\bugtest> python -m virtualenv .
Using base prefix 'C:\\Program Files\\Python36'
New python executable in C:\Users\$scuthbertson\Desktop\bugtest\Scripts\python.exe
Installing setuptools, pip, wheel...
  Complete output from command C:\Users\$scuthberts...t\Scripts\python.exe - setuptools pip wheel:
  Collecting setuptools
  Using cached setuptools-39.0.1-py2.py3-none-any.whl
Collecting pip
  Using cached pip-9.0.3-py2.py3-none-any.whl
Collecting wheel
  Using cached wheel-0.30.0-py2.py3-none-any.whl
Installing collected packages: setuptools, pip, wheel
Exception:
Traceback (most recent call last):
  File "C:\Program Files\Python36\Lib\distutils\util.py", line 202, in subst_vars
    return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
  File "C:\Users\$scuthbertson\Desktop\bugtest\lib\re.py", line 191, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "C:\Program Files\Python36\Lib\distutils\util.py", line 199, in _subst
    return os.environ[var_name]
  File "C:\Users\$scuthbertson\Desktop\bugtest\lib\os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'scuthbertson'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\virtualenv_support\pip-9.0.1-py2.py3-none-any.whl\pip\basecommand.py
", line 215, in main
    status = self.run(options, args)
  File "C:\Program Files\Python36\lib\site-packages\virtualenv_support\pip-9.0.1-py2.py3-none-any.whl\pip\commands\insta
ll.py", line 342, in run
    prefix=options.prefix_path,
  File "C:\Program Files\Python36\lib\site-packages\virtualenv_support\pip-9.0.1-py2.py3-none-any.whl\pip\req\req_set.py
", line 784, in install
    **kwargs
  File "C:\Program Files\Python36\lib\site-packages\virtualenv_support\pip-9.0.1-py2.py3-none-any.whl\pip\req\req_instal
l.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "C:\Program Files\Python36\lib\site-packages\virtualenv_support\pip-9.0.1-py2.py3-none-any.whl\pip\req\req_instal
l.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "C:\Program Files\Python36\lib\site-packages\virtualenv_support\pip-9.0.1-py2.py3-none-any.whl\pip\wheel.py", lin
e 247, in move_wheel_files
    prefix=prefix,
  File "C:\Program Files\Python36\lib\site-packages\virtualenv_support\pip-9.0.1-py2.py3-none-any.whl\pip\locations.py",
 line 153, in distutils_scheme
    i.finalize_options()
  File "C:\Program Files\Python36\Lib\distutils\command\install.py", line 307, in finalize_options
    self.expand_basedirs()
  File "C:\Program Files\Python36\Lib\distutils\command\install.py", line 475, in expand_basedirs
    self._expand_attrs(['install_base', 'install_platbase', 'root'])
  File "C:\Program Files\Python36\Lib\distutils\command\install.py", line 469, in _expand_attrs
    val = subst_vars(val, self.config_vars)
  File "C:\Program Files\Python36\Lib\distutils\util.py", line 204, in subst_vars
    raise ValueError("invalid variable '$%s'" % var)
ValueError: invalid variable '$'scuthbertson''
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\lib\site-packages\virtualenv.py", line 2328, in <module>
    main()
  File "C:\Program Files\Python36\lib\site-packages\virtualenv.py", line 713, in main
    symlink=options.symlink)
  File "C:\Program Files\Python36\lib\site-packages\virtualenv.py", line 945, in create_environment
    download=download,
  File "C:\Program Files\Python36\lib\site-packages\virtualenv.py", line 901, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "C:\Program Files\Python36\lib\site-packages\virtualenv.py", line 797, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command C:\Users\$scuthberts...t\Scripts\python.exe - setuptools pip wheel failed with error code 2
PS C:\Users\$scuthbertson\Desktop\bugtest>

@philosophicles :看起来与路径中的汉字或空格不同。 你能打开一个新书吗?

顺便说一句,venv也会受到影响,并且如果在venv的https://bugs.python.org/上也打开了一个问题,那就太好了。

@philosophicles这可能不是错误-似乎正在发生,因为distutils$cuthbertson视为占位符,并试图将其替换为未找到的变量。 请参阅文档的这一部分

我将针对当前问题分别提出问题(在virtualenv和venv中)。

@vsajip-我认为这绝对是一个错误。 我看了您参考的文档,但这是供使用distutils开发的人员的API参考。 我只是想在Windows下运行一个简单的命令,例如> python -m virtualenv . ,并遇到致命错误,该错误阻止了virtualenv进行应有的操作。 我完全不必关心virtualenv的内部实现,distutils的工作原理,甚至我的完整目录路径是什么。 Windows目录路径包含$是合法的,因此,理想情况下应支持它们。

由于此问题最近没有活动,因此已被自动标记为陈旧。 如果没有进一步的活动,它将关闭。 如果您想保持打开状态,只需添加一条评论即可。 感谢您的贡献。

@stale关闭了此....但是可以ping通。 这仍然是一个错误...但是如果在2.7.x上未修复,我可以...我只需要知道

现在,此问题已得到解决,只要文件系统编解码器可以处理它,我们也将处理它。在谈论utf-8。

@gaborbernat谢谢++

@gaborbernat ,您好,此问题在最新的master分支中已解决吗?
我使用了master分支,并得到类似于issue#1375的错误。
如果没有,我可以创建PR来解决此问题。

不在master分支中,而是rewrite分支,它将很快替换master。

好的,谢谢您的回复。

此页面是否有帮助?
0 / 5 - 0 等级