运行python setup.py install会返回某些包的UnicodeDecodeError

时间:2015-12-26 17:31:07

标签: python-3.x encoding cmd installation building

  • 我在Windows 7 64位上使用Python 3.5.0
  • 我的用户名完整的计算机名称都包含斯拉夫字符:ł
  • 因此,此字符位于某些文件路径环境变量
  • 编辑:通常我的活动代码页是852

我在尝试安装一些软件包时(不是每个软件包)都在我的CMD上出现此错误:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x88 in position "some_number": character maps to <undefined>

包lib2d的示例:

C:\Python35\Scripts\lib2d-0.0.2> c:\python35\python.exe setup.py install
running install
running build
running build_py
running build_ext
building '_lib2d' extension
Traceback (most recent call last):
  File "setup.py", line 51, in <module>
    scripts=['scripts/premultiplyalpha.py']
  File "c:\python35\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "c:\python35\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "c:\python35\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\python35\lib\distutils\command\install.py", line 539, in run
    self.run_command('build')
  File "c:\python35\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\python35\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\python35\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "c:\python35\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\python35\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\python35\lib\distutils\command\build_ext.py", line 338, in run
    self.build_extensions()
  File "c:\python35\lib\distutils\command\build_ext.py", line 447, in    build_extensions
    self._build_extensions_serial()
  File "c:\python35\lib\distutils\command\build_ext.py", line 472, in _build_extensions_serial
    self.build_extension(ext)
  File "c:\python35\lib\distutils\command\build_ext.py", line 532, in build_extension
    depends=ext.depends)
  File "c:\python35\lib\distutils\_msvccompiler.py", line 315, in compile
    self.initialize()
  File "c:\python35\lib\distutils\_msvccompiler.py", line 208, in initialize
    vc_env = _get_vc_env(plat_spec)
  File "c:\python35\lib\distutils\_msvccompiler.py", line 90, in _get_vc_env
    universal_newlines=True,
  File "c:\python35\lib\subprocess.py", line 629, in check_output
    **kwargs).stdout
  File "c:\python35\lib\subprocess.py", line 698, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "c:\python35\lib\subprocess.py", line 1055, in communicate
    stdout = self.stdout.read()
  File "c:\python35\lib\encodings\cp1250.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x88 in position 162: character maps to <undefined>  

pip install lib2d构建车轮发生类似的错误 pipwheels是最新的

我做了一些研究,结果显示:
1. 代码页852 中的byte 0x88是:ł - LATIN SMALL LETTER L WITH STROKE
2.在用户和计算机名称中使用“非标准字符”是非常不明智的(我年轻且缺乏经验) 3.更改完整的计算机名称是个坏主意,因为许可证问题以及现在正在运行的其他程序可能由于混乱的变化而停止工作 4. Python安装程序尝试在代码页1250 中解释该字符未定义的字符 5. Python不应该对 cp852 不熟悉,但错误地假设CMD有 cp1250
6. cp1250 中的ł - LATIN SMALL LETTER L WITH STROKEbyte 0xB3
这似乎是为什么建筑失败的唯一原因 8.其他“非标准字符用户”可能会遇到同样的问题,因为bytes: 0x81; 0x83; 0x90; 0x98; cp1250 中未分配,但在 cp852 中分配; CP775 ; cp 437 ;和其他

那么,有没有办法解决这个安装/构建障碍以及如何做到这一点?
也许我应该改变和/或添加一些东西到Pythons文件 codecs.py ? - 试图猜测

我在CMD中尝试了chcp 1250但它产生了另一个,这次是不同的错误(参见下面的示例)。

包lib2d的示例:

C:\Python35\Scripts\lib2d-0.0.2> c:\python35\python.exe setup.py install
running install
running build
running build_py
running build_ext
building '_lib2d' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\src
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Ic:\python35\include -Ic:\python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /Tcsrc/anim.c /Fobuild\temp.win-amd64-3.5\Release\src/anim.obj -std=c99
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
anim.c
src/anim.c(1): fatal error C1083: Cannot open include file: 'lib2d.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

解决这个其他错误是一条更简单的道路,如果是这样的话怎么办?

1 个答案:

答案 0 :(得分:0)

你必须使用&#34; pip3.5&#34; (如果存在或者只是&#34; pip3&#34;),安装程序而不是&#34; pip&#34;。

&#34;匹&#34;执行python2.x解释器,它不支持UTF-8编码,这就是你获得UnicodeDecodeError的原因。