Virtualenv: パス内の非ASCII車の問題

作成日 2013年07月29日  ·  20コメント  ·  ソース: pypa/virtualenv

これが#186に関連しているかどうかはわかりませんが、Windows 8にPythonを新規インストールすると、パスC:\ Users \ oncleben \ Dropbox \ Development \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

最も参考になるコメント

これは修正されました。ファイルシステムコーデックが処理できる限り、処理も行います👍そうでない場合は、適切なエラーメッセージが表示されます👍python3.6より前のWindowsでは、これはmcbsコーデックを意味します👍以降のすべての場合utf-8について話している。

全てのコメント20件

こんにちは、
ここでまったく同じ問題が発生しました:
Python v2.7.5
Win764ビット
自由に再現可能

#453のように見えます

この問題は、Pythonv2.7.2を搭載したMacOS X10.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パッチがありますが、

@ yan12125-あなたのPRが正しいかどうかはdistlib問題に関連していることは明らかではありません。これは、venvが正しく作成されたことをテストするときに呼び出されるvirtualenv別のバグのようです。

これを解決しようとするプルリクエストはたくさんあります。

  • #900(#875):私が開いた、すべてのテストに合格
  • #902(#894):@ aodagによって開かれました
  • #907(#453):@ magresによって開かれました
  • #908(#492):@ atykhonovによって開かれました
  • #912(#630): @ dholthによって開かれ

AppveyorのようなWindowsテスト環境も必要だと思います。 pypa / pipはすでにそれを使用しています。

FI、Debian GNU / Linux 9.2、Python2.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で修正されていなくても大丈夫です...私は知る必要があります

これは修正されました。ファイルシステムコーデックが処理できる限り、処理も行います👍そうでない場合は、適切なエラーメッセージが表示されます👍python3.6より前のWindowsでは、これはmcbsコーデックを意味します👍以降のすべての場合utf-8について話している。

@gaborbernatありがとう++

こんにちは@gaborbernat 、この問題は最新のマスターブランチで修正されていますか?
マスターブランチを使用しましたが、 issue#1375と同様のエラーが発生しました。
そうでない場合は、この問題を修正するためのPRを作成できます。

マスターブランチにはありませんが、まもなくマスターに置き換わるrewriteブランチにあります。

OK、お返事ありがとうございます。

このページは役に立ちましたか?
0 / 5 - 0 評価