pip: pip install codepage error (sqlalchemy,windows)
I have changed code page in my cmd to 65001 (it’s utf-8), and while installing sqlalchemy by pip:
c:\Program Files\Python35\Scripts>pip3.exe install sqlalchemy
I obtained next error:
Collecting sqlalchemy
Using cached SQLAlchemy-1.1.3.tar.gz
Installing collected packages: sqlalchemy
Running setup.py install for sqlalchemy ... error
Exception:
Traceback (most recent call last):
File "c:\program files\python35\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
File "c:\program files\python35\lib\encodings\cp65001.py", line 17, in decode
return codecs.code_page_decode(65001, input, errors, True)
UnicodeDecodeError: 'CP_UTF8' codec can't decode bytes in position 0--1: No mapping for the Unicode character exists in the target code page.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files\python35\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\program files\python35\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "c:\program files\python35\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "c:\program files\python35\lib\site-packages\pip\req\req_install.py", line 878, in install
spinner=spinner,
File "c:\program files\python35\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File "c:\program files\python35\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 34: invalid continuation byte
To solve this, change you code page to 866
chcp 866
And try to install sqlalchemy once again.
Issue on sqlalchemy: https://bitbucket.org/zzzeek/sqlalchemy/issues/3851/pip-install-error-windows-10
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 8
- Comments: 23 (12 by maintainers)
Links to this issue
- python - pipでpyperclipがインストールできません: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 - スタック・オーバーフロー
- UnicodeDecodeError при pip-установке библиотеки geopandas на Python 3.6 на Windows - Stack Overflow на русском
- Pip install Unicode error when having non-ASCII characters in your User folder name on Windows
Commits related to this issue
- Add a NEWS entry for #4310 which may cover #4110, #4251 and #3992 — committed to sakurai-youhei/pip by sakurai-youhei 7 years ago
I’ve installed 10.0.0.dev0 with bellow command because Windows locks pip.exe and “users” doesn’t have git client. It worked.
I write fix for me. In
/site-packages/pip/compat/__init__.py
I add:…
So I
locale.getpreferredencoding()
return mycp1251
Then I check if characters between 128 (\x80
) and 255 (\xff
) I convert it from my local code page, else I convert by utf-8, then join converted string and return.Also, what is actually in output (log by
print("// LOGGING /", s, end="")
):As you can see, here is 3 lines what contain my local language.
So… pip on windows is basically broken since more than half a year without a convenient way for a temporary fix? pip-10 is not released and I don’t see any pre-release either.
So a new year has come and there is still no concrete plan for Pip 10. Would it be plausible to have a 9.0.2 to include this fix, please? This is clearly an issue that affects people, and one those affected are highly unlikely to know how to solve.
Fundamentally, I believe the problem is that Visual C can produce output that is in a mix of the ANSI and the OEM codepages when run with stdout directed to a pipe. This means that the output is in practice un-decodable to Unicode.
At the moment, pip fails with a UnicodeError as a result of this. We’re working on a patch that allows pip to produce output without failing, although the output will still contain mojibake as it is the data itself that is in error.
I personally agree with hasufell’s point. Newbies (I guess they’d be students) have been wasting time due to this issue in Japan because of majority of Japanese Windows (cp932). I wish pip were not a blocker but a helper of newbies’ start-up in Python’s ecosystem.
I seen this issue also happen with packages that have cython extension modules (aiohttp, yarl) in packages on 3.6 when they did not have wheels for 3.6 on PyPi. Note this bug does not appear when pip installing bdist_wheel’s even if there are no c/cython extension modules.