Dust8 的博客

读书百遍其义自见

0%

python3.7下使用scrapy

python 更新到 3.7 版本后,运行 scrapy 报错。

1
2
3
def write(self, data, async=False):
^
SyntaxError: invalid syntax

原因

由于 python 版本的升级,async 成了关键字,导致 scrapy 的依赖库 twisted 报错.

##中国程序员解决办法
百度出来的居然都是改源代码。真的很讽刺,感觉小白喜欢复制粘贴,大牛都不上网。

##国外程序员解决办法
可以通过提交补丁的方式来解决
1.方法一

1
pip install git+https://github.com/scrapy/scrapy@master --no-dependencies --upgrade

2.方法二

1
pip install git+https://github.com/twisted/twisted.git@trunk

经过实验都可以。要等下一个正式版本的发布,这个问题才会彻底解决。