Windows安装scrapy

今天在win 10下安装scrapy时遇到了点麻烦。

首先pip版本:

pip 9.0.1 from c:\users\dell\appdata\local\programs\python\python36\lib\site-packages (python 3.6)

执行pip install scrapy遇到错误:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 2: invalid continuation byte

GitHub上很多相关issue,指出这是pip的锅,pip10版本会修复。

一个临时解决的办法:找到C:\Users\dell\AppData\Local\Programs\Python\Python36\Lib\site-packages\pip\compat\__init_.py文件,找到这段代码:

if sys.version_info >= (3,):
    def console_to_str(s):
        try:
            return s.decode(sys.__stdout__.encoding)
        except UnicodeDecodeError:
            return s.decode('utf-8')

    def native_str(s, replace=False):
        if isinstance(s, bytes):
            return s.decode('utf-8', 'replace' if replace else 'strict')
        return s

把其中return s.decode('utf-8')替换成return s.decode('gbk')就解决问题了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。