报错内容
Traceback (most recent call last):
File "/Library/anaconda3/bin/pyspider", line 6, in
from pyspider.run import main
File "/Library/anaconda3/lib/python3.7/site-packages/pyspider/run.py", line 231
async=True, get_object=False, no_input=False):
^
SyntaxError: invalid syntax
原因是async和await从 python3.7 开始已经加入保留关键字中. 参考: What’s New In Python 3.7, 所以async不能作为函数的参数名.
改正:
1.修改/Library/anaconda3/lib/python3.7/site-packages/pyspider路径下的python文件中的async为shark(全部替换)
1.run.py
2.fetcher\tornado_fetcher.py
3.webui\app.py
使用替换命令(注意路径)
sed -i '' 's/async/shark/g' run.py
sed -i '' 's/async/shark/g' tornado_fetcher.py
sed -i '' 's/async/shark/g' app.py
2.降低WsgiDAV版本
python -m pip install wsgidav==2.4.1
再运行pyspider all
依然报错
Error: Could not create web server listening on port 25555
[I 190621 11:14:50 result_worker:49] result_worker starting...
Error: Could not create web server listening on port 25555
[I 190621 11:14:51 processor:211] processor starting...
[I 190621 11:14:51 tornado_fetcher:638] fetcher starting...
[I 190621 11:14:51 scheduler:647] scheduler starting...
[I 190621 11:14:51 scheduler:782] scheduler.xmlrpc listening on 127.0.0.1:23333
[I 190621 11:14:51 scheduler:586] in 5m: new:0,success:0,retry:0,failed:0
[I 190621 11:14:51 app:76] webui running on 0.0.0.0:5000
Error: Could not create web server listening on port 25555
Error: Could not create web server listening on port 25555
Error: Could not create web server listening on port 25555
Error: Could not create web server listening on port 25555
解决方法:
Reboot the PC,or remove phantomjs can fix it
查看端口,然后kill phantomjs
再运行pyspider all 成功
这时pyspider的Web服务就会在本地5000端口运行。直接在浏览器中打开http://localhost:5000/,即可进入pyspider的WebUI管理页面,这证明pyspider已经安装成功了。