今天有人问我安装pyspider的问题,因为我以前也没有安装过,所以只能根据他提供的报错信息来百度解决,不过到最后还是没能解决问题,最后决定还是我亲自来安装试试(安装环境:python3.6)。
第一步: 安装pyspider
在cmd中运行
pip install pyspider
如果你安装成功,那么恭喜你。进行下一步。
第二步:启动pyspider
在cmd中运行
pyspider all
然后cmd中会给出执行信息。
如果信息中出现
[ ]phantomjs not found,continue running without it
那你就需要下载phantomjs,然后把phantomjs.exe文件复制到与python.exe文件同一目录下(如果编辑器是anaconda,那就放到与anaconda中的python.exe同一目录下)。
然后再次运行 pyspider all ,就会发现 phantomjs not found,continue running without it 消失了,多了一句 phantomjs fetcher running on port 25555。
我解决这个问题后再次运行,出现报错(其实是和上一个错误一起出现的),报错信息为
ValueError: Invalid configuration:
- Deprecated option 'domaincontroller': use 'http_authenticator.domain_controller' instead.
然后我就百度找解决方法。
这个报错的原因是因为WsgiDAV发布了新版本3.x,新版本是测试版,有问题。
最后发现解决方式的方式有两种。
第一种:更换版本
pip uninstall wsgidav
pip install wsgidav==2.4.1 #也可以安装其它2.x的版本
第二种:如报错信息给的提示,更改库文件的代码
#把Python36\Lib\site-packages\pyspider\webui\webdav.py文件的209行代码
'domaincontroller': NeedAuthController(app),
#改为
'http_authenticator':{
'HTTPAuthenticator':NeedAuthController(app),
},
改好后,记得保存退出哦
然后,再次执行pyspider all,好了,没报错了。(如果还有报错,那真是太不幸了。)
第三步 在浏览器中访问http://localhost:5000/

访问成功则表示pyspider安装成功。
最后提醒一下pyspider与python3.7会有关键字冲突,然后报错,报错信息为:

这种错误,有两种办法解决:
- 你将自己的python版本降低。
- 告诉开发者修改代码。
网友评论