Installation failed on windows of python 3.8
liudonghua123 opened this issue · 4 comments
I tried to install mdv
in my Windows, the version of python is 3.8.6
. Then it failed with the following errors.
D:\code\weixin\emp-ide>which pip
/c/Users/Liu.D.H/AppData/Local/Microsoft/WindowsApps/pip
D:\code\weixin\emp-ide>which python
/c/Users/Liu.D.H/AppData/Local/Microsoft/WindowsApps/python
D:\code\weixin\emp-ide>pip install mdv
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting mdv
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/70/6d/831e188f8079c9793eac4f62ae55d04a93d90979fd2d8271113687605380/mdv-1.7.4.tar.gz (54 kB)
|████████████████████████████████| 54 kB 318 kB/s
ERROR: Command errored out with exit status 1:
command: 'C:\Users\Liu.D.H\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Liu.D.H\\AppData\\Local\\Temp\\pip-install-ut58pvn5\\mdv\\setup.py'"'"'; __file__='"'"'C:\\Users\\Liu.D.H\\AppData\\Local\\Temp\\pip-install-ut58pvn5\\mdv\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Liu.D.H\AppData\Local\Temp\pip-pip-egg-info-0f_vidqt'
cwd: C:\Users\Liu.D.H\AppData\Local\Temp\pip-install-ut58pvn5\mdv\
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Liu.D.H\AppData\Local\Temp\pip-install-ut58pvn5\mdv\setup.py", line 20, in <module>
md = fd.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x82 in position 12007: illegal multibyte sequence
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\Liu.D.H\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.
D:\code\weixin\emp-ide>
The key error seems to be UnicodeDecodeError: 'gbk' codec can't decode byte 0x82 in position 12007: illegal multibyte sequence
.
The current chcp
is 936, I also tried chcp 65001
, however, it failed with the same errors.
I checked the code, and find it's maybe a problem with the default encoding of python 3 on windows.
And even I set PYTHONIOENCODING
, it would not work as expected.
A quick fix would be to set encoding (utf-8) of open in setup.py
.
terminal_markdown_viewer/setup.py
Lines 19 to 20 in 80f333b
D:\code\weixin\emp-ide>python -c "import sys, os, locale; print(os.environ.get('PYTHONIOENCODING')); print(sys.stdin.encoding); print(sys.stdout.encoding); print(locale.getdefaultlocale()); print(locale.getpreferredencoding())"
None
utf-8
utf-8
('en_US', 'cp936')
cp936
D:\code\weixin\emp-ide>set PYTHONIOENCODING=utf-8
D:\code\weixin\emp-ide>python -c "import sys, os, locale; print(os.environ.get('PYTHONIOENCODING')); print(sys.stdin.encoding); print(sys.stdout.encoding); print(locale.getdefaultlocale()); print(locale.getpreferredencoding())"
utf-8
utf-8
utf-8
('en_US', 'cp936')
cp936
D:\code\weixin\emp-ide>
see also ipython/ipython#10011, and the actual implementation of _locale._getdefaultlocale
.
I also tried to install mdv
programmatically but failed too.
C:\Users\Liu.D.H>python
Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _locale
>>> _locale._getdefaultlocale = (lambda *args: ['zh_CN', 'utf-8'])
>>> import sys,os,locale
>>> print(os.environ.get('PYTHONIOENCODING')); print(sys.stdin.encoding); print(sys.stdout.encoding); print(locale.getdefaultlocale()); print(locale.getpreferredencoding())
utf-8
utf-8
utf-8
('zh_CN', 'utf-8')
utf-8
>>> import pip
>>> pip.main(['install','mdv'])
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting mdv
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/70/6d/831e188f8079c9793eac4f62ae55d04a93d90979fd2d8271113687605380/mdv-1.7.4.tar.gz (54 kB)
ERROR: Command errored out with exit status 1:
command: 'C:\Users\Liu.D.H\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Liu.D.H\\AppData\\Local\\Temp\\pip-install-81aeum8n\\mdv\\setup.py'"'"'; __file__='"'"'C:\\Users\\Liu.D.H\\AppData\\Local\\Temp\\pip-install-81aeum8n\\mdv\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Liu.D.H\AppData\Local\Temp\pip-pip-egg-info-xx5mibv6'
cwd: C:\Users\Liu.D.H\AppData\Local\Temp\pip-install-81aeum8n\mdv\
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Liu.D.H\AppData\Local\Temp\pip-install-81aeum8n\mdv\setup.py", line 20, in <module>
md = fd.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x82 in position 12007: illegal multibyte sequence
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\Liu.D.H\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.
1
>>>
#103
Maybe I solved it, you can try it.