pip錯誤:'utf-8' codec can't decode byte解決方法


windows下python3.6安裝flask時報錯:

Exception:
Traceback (most recent call last):
  File "d:\python36\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 0xd5 in position 2: invalid continuation byte

原因是windows下命令行的代碼頁為GBK編碼而非GBK。

解決方法:
找到報錯文件,即python安裝目錄下\Lib\site-packages\pip\compat的__init__.py,文件中約75行

def console_to_str(s):
    try:
        return s.decode(sys.__stdout__.encoding)
    except UnicodeDecodeError:
        return s.decode('utf-8')

將’utf-8’修改為’gbk’即可


免責聲明!

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



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