Anaconda安裝Tensorflow報錯UnicodeDecodeError: 'utf-8' codec can't decode ## invalid start byte的問題之解決


轉載請注明出處:http://blog.csdn.net/apply51/article/details/79516002

本人在使用Anaconda prompt通過命令:

pip install --ignore-installed --upgrade tensorflow 

安裝tensorflow時報錯:

Building wheels for collected packages: absl-py, gast, termcolor, html5lib Running setup.py bdist_wheel for absl-py ... error Failed building wheel for absl-py Running setup.py clean for absl-py Running setup.py bdist_wheel for gast ... error Failed building wheel for gast Running setup.py clean for gast Running setup.py bdist_wheel for termcolor ... error Failed building wheel for termcolor Running setup.py clean for termcolor Running setup.py bdist_wheel for html5lib ... error Failed building wheel for html5lib Running setup.py clean for html5lib Failed to build absl-py gast termcolor html5lib Installing collected packages: numpy, setuptools, six, protobuf, grpcio, werkzeug, markdown, wheel, html5lib, bleach, tensorboard, absl-py, astor, gast, termcolor, tensorflow Running setup.py install for html5lib ... error Exception: Traceback (most recent call last): File "C:\DeepLearning\Anaconda3\envs\tensorflow\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 0xc1 in position 45: invalid start byte
 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\DeepLearning\Anaconda3\envs\tensorflow\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "C:\DeepLearning\Anaconda3\envs\tensorflow\lib\site-packages\pip\commands\install.py", line 342, in run prefix=options.prefix_path, File "C:\DeepLearning\Anaconda3\envs\tensorflow\lib\site-packages\pip\req\req_set.py", line 784, in install **kwargs File "C:\DeepLearning\Anaconda3\envs\tensorflow\lib\site-packages\pip\req\req_install.py", line 878, in install spinner=spinner, File "C:\DeepLearning\Anaconda3\envs\tensorflow\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess line = console_to_str(proc.stdout.readline()) File "C:\DeepLearning\Anaconda3\envs\tensorflow\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 0xc1 in position 45: invalid start byte

找了一大片的解決方案,有使用 Notepad++改編碼格式的,也有添加三條代碼的:

sys.getdefaultencoding() != 'gbk': reload(sys) sys.setdefaultencoding('gbk')

都不能解決我的問題,最后的解決辦法是,根據最后的報錯提示行:

File "C:\DeepLearning\Anaconda3\envs\tensorflow\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str return s.decode('utf_8')

找到__init__.py,使用Notepad++打開,將提示的第75行進行更改:

return s.decode(sys.__stdout__.encoding) 應改為 return s.decode('cp936')

更改__init__.py時記得備份一下,以備以后需要使用到原版。

折騰了一天,問題終於解決,開心並記錄之。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM