報錯信息如下:
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