• 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:DeepLearningAnaconda3envs	ensorflowlibsite-packagespipcompat\__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:DeepLearningAnaconda3envs	ensorflowlibsite-packagespipasecommand.py", line 215, in main
        status = self.run(options, args)
      File "C:DeepLearningAnaconda3envs	ensorflowlibsite-packagespipcommandsinstall.py", line 342, in run
        prefix=options.prefix_path,
      File "C:DeepLearningAnaconda3envs	ensorflowlibsite-packagespip
    eq
    eq_set.py", line 784, in install
        **kwargs
      File "C:DeepLearningAnaconda3envs	ensorflowlibsite-packagespip
    eq
    eq_install.py", line 878, in install
        spinner=spinner,
      File "C:DeepLearningAnaconda3envs	ensorflowlibsite-packagespiputils\__init__.py", line 676, in call_subprocess
        line = console_to_str(proc.stdout.readline())
      File "C:DeepLearningAnaconda3envs	ensorflowlibsite-packagespipcompat\__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:DeepLearningAnaconda3envs	ensorflowlibsite-packagespipcompat\__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时记得备份一下,以备以后需要使用到原版。

    折腾了一天,问题终于解决,开心并记录之。

  • 相关阅读:
    马士兵讲jsp项目--BBS项目分析笔记
    ubuntu 14.04中安装phpmyadmin即mysql图形管理界面
    Xman冬令营writeup
    python--gevent协程及协程概念
    python--multiprocessing多进程总结
    python--threading多线程总结
    浅析Java中print、printf、println的区别
    内存泄漏与内存溢出
    Java中==和equals的区别,equals和hashCode的区别
    vue五十七:电影院售票项目案例之使用swiper实现轮播功能
  • 原文地址:https://www.cnblogs.com/liangliu/p/8544176.html
Copyright © 2020-2023  润新知