UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xce in position 72:
E:\CodeFile\Tensorflow\fast-neural-style-tensorflow>pip install pyyaml
Collecting pyyaml
Downloading http://mirrors.aliyun.com/pypi/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz (253kB)
100% |████████████████████████████████| 256kB 14kB/s
Building wheels for collected packages: pyyaml
Running setup.py bdist_wheel for pyyaml … error
Failed building wheel for pyyaml
Running setup.py clean for pyyaml
Failed to build pyyaml
Installing collected packages: pyyaml
Running setup.py install for pyyaml … error
Exception:
Traceback (most recent call last):
File “d:\pfiles\python36\lib\site-packages\pip\compat\__init__.py”, line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xce in position 72: invalid continuation byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “d:\pfiles\python36\lib\site-packages\pip\basecommand.py”, line 215, in main
status = self.run(options, args)
File “d:\pfiles\python36\lib\site-packages\pip\commands\install.py”, line 342, in run
prefix=options.prefix_path,
File “d:\pfiles\python36\lib\site-packages\pip\req\req_set.py”, line 784, in install
**kwargs
File “d:\pfiles\python36\lib\site-packages\pip\req\req_install.py”, line 878, in install
spinner=spinner,
File “d:\pfiles\python36\lib\site-packages\pip\utils\__init__.py”, line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File “d:\pfiles\python36\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 0xce in position 72: invalid continuation byt
解决方案
看起来是标准输出流的编码不对的缘故。使用chcp命令,更改代码页为65001(UTF-8)再执行pip安装命令即可。
另外提供一些chcp命令的参考:
chcp 65001 就是换成UTF-8代码页
chcp 936 可以换回默认的GBK
chcp 437 是美国英语