码迷,mamicode.com
首页 > 编程语言 > 详细

Win10上Python3通过pip install Twisted安装时出现UnicodeDecodeError

时间:2018-03-05 23:33:58      阅读:1841      评论:0      收藏:0      [点我收藏+]

标签:定位   out   adl   统一   出现   attr   readline   other   read   

pip install Twisted

报错:

C:\Windows\system32>pip install Twisted
Collecting Twisted
  Using cached Twisted-17.9.0.tar.bz2
Requirement already satisfied: zope.interface>=4.0.2 in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from Twisted)
Requirement already satisfied: constantly>=15.1 in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from Twisted)
Requirement already satisfied: incremental>=16.10.1 in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from Twisted)
Requirement already satisfied: Automat>=0.3.0 in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from Twisted)
Requirement already satisfied: hyperlink>=17.1.1 in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from Twisted)
Requirement already satisfied: setuptools in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from zope.interface>=4.0.2->Twisted)
Requirement already satisfied: attrs in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from Automat>=0.3.0->Twisted)
Requirement already satisfied: six in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from Automat>=0.3.0->Twisted)
Requirement already satisfied: idna>=2.5 in c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages (from hyperlink>=17.1.1->Twisted)
Installing collected packages: Twisted
  Running setup.py install for Twisted ... error
Exception:
Traceback (most recent call last):
  File "c:\users\xxx\appdata\local\programs\python\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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "c:\users\xxx\appdata\local\programs\python\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 0xd5 in position 2: invalid continuation byte

解决方案:

打开"c:\users\xxx\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py",定位至75行,修改return s.decode(‘utf-8‘)为return s.decode(‘cp936‘)

原因: 
编码问题,虽然py3统一用utf-8了。但win下的终端显示用的还是gbk编码。

Win10上Python3通过pip install Twisted安装时出现UnicodeDecodeError

标签:定位   out   adl   统一   出现   attr   readline   other   read   

原文地址:https://www.cnblogs.com/cnfangbo/p/8511692.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!