报错信息如下:
C:\Users\Administrator>pyspider all
Traceback (most recent call last):
File "f:\installation position\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "f:\installation position\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "F:\Installation position\Anaconda3\Scripts\pyspider.exe\__main__.py", line 5, in <module>
File "f:\installation position\anaconda3\lib\site-packages\pyspider\run.py", line 231
async=True, get_object=False, no_input=False):
^
SyntaxError: invalid syntax
报错原因: 在python3.7中 async 是关键字,是不能作为函数的参数名的。
解决方案:根据上诉报错信息,定位到pyspider的位置。
比如我的pyspider的位置为:f:\installation position\anaconda3\lib\site-packages\pyspider
使用PyCharm打开,然后在菜单栏依次点击 edit -> find -> find in path
然后输入async 来查找修改,如下图所示:
注意:
1、以下截图为修改后的截图,为了演示效果,我这里查找时用的是修改后的变量名,请读者查找时输入async
2、部分读者会显示导入包的名称,如SimpleAsyncHTTPClient 就别改,只改小写的变量名就行
这时重新输入命令就可以运行了!
C:\Users\Administrator>pyspider all
f:\installation position\anaconda3\lib\site-packages\pyspider\libs\utils.py:196: FutureWarning: timeout is not supported on your platform.
warnings.warn("timeout is not supported on your platform.", FutureWarning)
phantomjs fetcher running on port 25555
[I 200214 20:17:28 result_worker:49] result_worker starting...
[I 200214 20:17:30 processor:211] processor starting...
[I 200214 20:17:30 scheduler:647] scheduler starting...
[I 200214 20:17:30 scheduler:586] in 5m: new:0,success:0,retry:0,failed:0
[I 200214 20:17:31 tornado_fetcher:638] fetcher starting...
[I 200214 20:17:31 scheduler:782] scheduler.xmlrpc listening on 127.0.0.1:23333
[I 200214 20:17:31 app:76] webui running on 0.0.0.0:5000