Virtualenv: Problema con un automóvil no ASCII en el camino

Creado en 29 jul. 2013  ·  20Comentarios  ·  Fuente: pypa/virtualenv

No sé si esto está relacionado con # 186, pero con mi nueva instalación de Python en mi Windows 8, tengo el siguiente error al usar virtualenv en la ruta C: \ Users \ oncleben \ Dropbox \ Developement \ fraisDeSanté

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
lista de pips
nariz (1.3.0)
pepita (1,4)
Andamio (0.1.3)
herramientas de configuración (0.9.7)
virtualenv (1,10)

Editar:

bug help-wanted

Comentario más útil

Esto ahora se ha solucionado, siempre que el códec del sistema de archivos pueda manejarlo, lo manejaremos también 👍 si no, mostraremos el mensaje de error apropiado 👍 En Windows pre python3.6 esto implica el códec mcbs 👍 en todos los casos posteriores estamos hablando de utf-8.

Todos 20 comentarios

Hola,
Tengo exactamente el mismo problema aquí con:
python v2.7.5
Win7 de 64 bits
Se puede reproducir a voluntad

Parece # 453

Este problema también ocurre en Mac OS X 10.8.4 con Python v2.7.2:

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

La solicitud de extracción n. ° 187 mencionó algo sobre la codificación FS que difiere de la codificación predeterminada. ¿Probablemente la configuración del sistema lo resolvería?

La solución de atykhonov funciona para mí.

Bache. ¿Cualquier progreso? @atykhonov ¿Qué tal enviar su parche como solicitudes de extracción?

Ídem. El problema también ocurre en Linux, aquí con caracteres chinos:

$ 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.
>>> 

Tengo un parche WIP para este problema, aunque no se pueden hacer cosas antes de que se solucione el error en https://bitbucket.org/pypa/distlib/pull-requests/27 .

@ yan12125 - No estoy seguro de si su PR es correcto, vea mis comentarios al respecto. Además, no está claro que el volcado de la consola anterior se relacione con el problema distlib ; parece ser un error diferente en virtualenv que se invoca cuando se prueba que el venv se creó correctamente.

Hay muchas solicitudes de extracción que intentan resolver esto:

  • # 900 (# 875): abierto por mí, todas las pruebas pasaron
  • # 902 (# 894): abierto por @aodag
  • # 907 (# 453): abierto por @magres
  • # 908 (# 492): abierto por @atykhonov
  • # 912 (# 630): abierto por @dholth

Supongo que también es necesario un entorno de prueba de Windows como Appveyor. pypa / pip ya lo está

FI, obtuve el mismo error en 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.

Por lo que valga, puedo reproducir este problema en Windows 7, Python 3.6.4, virtualenv 15.1.0, cuando trabajo con una cuenta de usuario con un nombre de usuario que comienza con $ .

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 : parece un problema diferente a los caracteres chinos o los espacios en la ruta. ¿Podrías abrir una nueva edición?

Por cierto, venv también se ve afectado, y sería genial si se abriera un problema en https://bugs.python.org/ para venv también.

@philosophicles Esto puede no ser un error; parece estar sucediendo porque distutils ve $cuthbertson como marcador de posición e intenta reemplazarlo con una variable, que no se encuentra. Consulte esta parte de la documentación .

Plantearé cuestiones separadas (tanto en virtualenv como en venv) para mi problema actual.

@vsajip : mi opinión es que definitivamente es un error. He mirado la documentación a la que hace referencia, pero esa es una referencia de API para alguien que desarrolla usando distutils. Solo estoy tratando de ejecutar un comando simple como > python -m virtualenv . en Windows, y encuentro un error fatal que impide que virtualenv haga lo que debe hacer. No debería tener que preocuparme en absoluto por la implementación interna de virtualenv, o cómo funciona distutils, o incluso cuál es mi ruta de directorio completa. Es legítimo que las rutas de directorio de Windows contengan $ por lo que, idealmente, deberían ser compatibles.

Este problema se ha marcado automáticamente como obsoleto porque no ha tenido actividad reciente. Se cerrará si no se produce más actividad. Simplemente agregue un comentario si desea mantenerlo abierto. Gracias por sus aportaciones.

@stale cerró esto .... pero ping. Esto sigue siendo un error ... pero estoy bien si esto no se soluciona en 2.7.x ... solo necesito saber

Esto ahora se ha solucionado, siempre que el códec del sistema de archivos pueda manejarlo, lo manejaremos también 👍 si no, mostraremos el mensaje de error apropiado 👍 En Windows pre python3.6 esto implica el códec mcbs 👍 en todos los casos posteriores estamos hablando de utf-8.

@gaborbernat Gracias ++

Hola @gaborbernat , ¿se solucionó este problema en la última rama maestra?
Usé la rama maestra y obtuve errores similares al número 1375 .
si no, puedo crear un PR para solucionar este problema.

No en la rama principal, sino en la rama rewrite que pronto reemplazará a la principal.

OK, gracias por tu respuesta.

¿Fue útil esta página
0 / 5 - 0 calificaciones