Closed
Description
Environment
- pip version: 20.2.3 - 20.2.4
- Python version: 3.9
- OS: Windows 10 Home
Description
A fresh installation of Python 3.9 can't install any libraries with pip if username contains non-ASCII characters.
Probably it affects any paths with non-ASCII characters.
This is not new and happened before multiple times across recent years. One of the latest examples is #4984. I kindly suggest adding a unittest for that error.
This is especially bad because Python is number one language for education now. And such errors can confuse children a lot - they are not developers and are likely to have both prerequisites for this bug: 1) username in native language 2) installing Python with default settings
Expected behavior
pip is expected to work
How to Reproduce
- Create a user with non-ASCII name
- Install Python 3.9 with default settings
- Try to install any library with pip, for example
pip install pylint
- An error occurs
Output
C:\Users\ФШЪЙAUC>C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\python.exe
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
C:\Users\ФШЪЙAUC>C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\python.exe -m pip install pylint
Collecting pylint
Downloading pylint-2.6.0-py3-none-any.whl (325 kB)
|--------------------------------| 325 kB 1.6 MB/s
Collecting mccabe<0.7,>=0.6
Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting isort<6,>=4.2.5
Downloading isort-5.6.4-py3-none-any.whl (98 kB)
|--------------------------------| 98 kB 6.4 MB/s
Collecting toml>=0.7.1
Downloading toml-0.10.1-py2.py3-none-any.whl (19 kB)
Collecting colorama; sys_platform == "win32"
Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting astroid<=2.5,>=2.4.0
Downloading astroid-2.4.2-py3-none-any.whl (213 kB)
|--------------------------------| 213 kB 6.4 MB/s
Collecting six~=1.12
Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting wrapt~=1.11
Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting lazy-object-proxy==1.4.*
Downloading lazy-object-proxy-1.4.3.tar.gz (34 kB)
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main
status = self.run(options, args)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
return func(self, options, args)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\commands\install.py", line 323, in run
requirement_set = resolver.resolve(
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 482, in prepare_linked_requirement
abstract_dist = _get_prepared_distribution(
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 91, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\distributions\sdist.py", line 38, in prepare_distribution_metadata
self._setup_isolation(finder)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\distributions\sdist.py", line 65, in _setup_isolation
self.req.build_env = BuildEnvironment()
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\build_env.py", line 82, in __init__
fp.write(textwrap.dedent(
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 152-154: character maps to <undefined>
WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available.
You should consider upgrading via the 'C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\python.exe -m pip install --upgrade pip' command.
C:\Users\ФШЪЙAUC>C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\python.exe -m pip install --upgrade pip
Collecting pip
Downloading pip-20.2.4-py2.py3-none-any.whl (1.5 MB)
|--------------------------------| 1.5 MB 2.2 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
WARNING: The scripts pip.exe, pip3.9.exe and pip3.exe are installed in 'C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.4
C:\Users\ФШЪЙAUC>C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\python.exe -m pip install pylint
Collecting pylint
Using cached pylint-2.6.0-py3-none-any.whl (325 kB)
Collecting astroid<=2.5,>=2.4.0
Using cached astroid-2.4.2-py3-none-any.whl (213 kB)
Collecting isort<6,>=4.2.5
Using cached isort-5.6.4-py3-none-any.whl (98 kB)
Collecting colorama; sys_platform == "win32"
Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting toml>=0.7.1
Using cached toml-0.10.1-py2.py3-none-any.whl (19 kB)
Collecting mccabe<0.7,>=0.6
Using cached mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting lazy-object-proxy==1.4.*
Using cached lazy-object-proxy-1.4.3.tar.gz (34 kB)
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main
status = self.run(options, args)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
return func(self, options, args)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\commands\install.py", line 323, in run
requirement_set = resolver.resolve(
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 388, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\legacy\resolver.py", line 340, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 482, in prepare_linked_requirement
abstract_dist = _get_prepared_distribution(
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\operations\prepare.py", line 91, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\distributions\sdist.py", line 38, in prepare_distribution_metadata
self._setup_isolation(finder)
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\distributions\sdist.py", line 65, in _setup_isolation
self.req.build_env = BuildEnvironment()
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\build_env.py", line 82, in __init__
fp.write(textwrap.dedent(
File "C:\Users\ФШЪЙAUC\AppData\Local\Programs\Python\Python39\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 152-154: character maps to <undefined>
C:\Users\ФШЪЙAUC>
Metadata
Metadata
Assignees
Labels
Stuff related to metadata generation / wheel generationStuff related to metadata generation / wheel generationRelated to text encoding and likely, UnicodeErrorsRelated to text encoding and likely, UnicodeErrorsWindows specificWindows specificFor situations where pip crashesFor situations where pip crashes