AliceNEET

导航

Python3.7 Scrapy crawl 运行出错解决方法

安装的是Python3.7,装上依赖包和scrapy后运行爬虫命令出错

1  File "D:\Python37\lib\site-packages\scrapy\extensions\telnet.py", line 12, in <module>
2     from twisted.conch import manhole, telnet
3   File "D:\Python37\lib\site-packages\twisted\conch\manhole.py", line 154
4     def write(self, data, async=False):
5                               ^
6 SyntaxError: invalid syntax
7 
8 Process finished with exit code 1

解决方法:

 1     def write(self, data, shark=False):
 2         self.handler.addOutput(data, shark)
 3 
 4     def addOutput(self, data, shark=False):
 5         if shark:
 6             self.terminal.eraseLine()
 7             self.terminal.cursorBackward(len(self.lineBuffer) + len(self.ps[self.pn]))
 8 
 9         self.terminal.write(data)
10 
11         if shark:
12             if self._needsNewline():
13                 self.terminal.nextLine()
14 
15             self.terminal.write(self.ps[self.pn])

 

 

将源码manhole.py中的async参数更改为shark(注意更换全部) 
可以直接点击错误跳转 
也可以通过文件路径查找 
D:\Python37\Lib\site-packages\twisted\conch\manhole.py

改完再运行就OK了

posted on 2018-08-06 20:57  AliceNEET  阅读(1979)  评论(0编辑  收藏  举报