解决win10安装Pyint失败

我的版本

pylint —version
pylint 2.2.2
astroid 2.1.0
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]

错误分析

执行安装指令pip install pylint,出现错误,错误信息如下:

Installing collected packages: wrapt, astroid, pylint
Running setup.py install for wrapt … error
Exception:
Traceback (most recent call last):
File “C:\\Users\\sigmarising\\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 0xa1 in position 43: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\\Users\\sigmarising\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\pip\\basecommand.py”, line 215, in main
status = self.run(options, args)
File “C:\\Users\\sigmarising\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\pip\\commands\\install.py”, line 342, in run
prefix=options.prefix_path,
File “C:\\Users\\sigmarising\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\pip\\req\\req_set.py”, line 784, in install
**kwargs
File “C:\\Users\\sigmarising\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\pip\\req\\req_install.py”, line 878, in install
spinner=spinner,
File “C:\\Users\\sigmarising\\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\\sigmarising\\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 0xa1 in position 43: invalid start byte

Windows上很多问题都是由于编码引起的,pylint安装失败也与编码有很大关系。

解决方案

1.定位到以下文件: C:\\Users\\acanprince\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages\\pip\\compat\\__init__.py 定位时需将路径中的_\\UsersNames__\\Python36_,更改为计算机具体情况 2.定位到文件的第75行,将源代码:

return s.decode(‘utf_8’)

更改为:

return s.decode(‘gbk’)

3.重新执行_pip install pylint_ 4.安装成功

(っ•̀ω•́)っ✎⁾⁾ 坚持技术学习、内容输出与分享,您的支持将鼓励我继续创作!(*/ω\*)
( • ̀ω•́ )✧如有疑问或需要技术讨论,请留言或发邮件到 aclearzhang@qq.com.(*・ω< ) 
  • 本文作者:: AClearZhang
  • 本文链接:: 1316.html
  • 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!