Open
Description
(Migrated from https://bugs.python.org/issue33193 - the below text is from a reply with more useful context than the OP)
An exotic case, but it also affects Linux:
python3.7 -m venv 'at$test'
Error: Command '['/home/maier/at$test/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 2.
[maier@nb19 ~]$ mkdir 'at$test'
mkdir: cannot create directory ‘at$test’: File exists
[maier@nb19 ~]$ cd 'at$test'
[maier@nb19 at$test]$ bin/python -m ensurepip
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Exception:
Traceback (most recent call last):
File "/usr/lib64/python3.7/distutils/util.py", line 187, in subst_vars
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
File "/usr/lib64/python3.7/re.py", line 198, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/usr/lib64/python3.7/distutils/util.py", line 184, in _subst
return os.environ[var_name]
File "/usr/lib64/python3.7/os.py", line 678, in __getitem__
raise KeyError(key) from None
KeyError: 'test'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/tmpppaapmyk/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/tmp/tmpppaapmyk/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/tmp/tmpppaapmyk/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 784, in install
**kwargs
File "/tmp/tmpppaapmyk/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/tmp/tmpppaapmyk/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/tmp/tmpppaapmyk/pip-9.0.1-py2.py3-none-any.whl/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/tmp/tmpppaapmyk/pip-9.0.1-py2.py3-none-any.whl/pip/locations.py", line 153, in distutils_scheme
i.finalize_options()
File "/usr/lib64/python3.7/distutils/command/install.py", line 307, in finalize_options
self.expand_basedirs()
File "/usr/lib64/python3.7/distutils/command/install.py", line 486, in expand_basedirs
self._expand_attrs(['install_base', 'install_platbase', 'root'])
File "/usr/lib64/python3.7/distutils/command/install.py", line 480, in _expand_attrs
val = subst_vars(val, self.config_vars)
File "/usr/lib64/python3.7/distutils/util.py", line 189, in subst_vars
raise ValueError("invalid variable '$%s'" % var)
ValueError: invalid variable '$'test''
So the venv actually gets created, but it's ensurepip which chokes on the $.