macbook安装pyspider比较费劲,一方面系统不让你随便写Library,另一方面python的各版本之间没有配套表,调起来很费劲。
经过踩坑后,最后还是决定用conda安装虚拟环境来跑pyspider
conda info --envs
conda create --name python36 python=3.6
conda activate python36
1. async问题
python3.7之后把async当成了关键字,pyspider中把async当成变量用,把pyspider中的async都改个名就行了。
2. pycurl: libcurl link-time ssl backends (secure-transport, openssl) do not include compile-time ssl b
libcurl是最麻烦的了,卸载pycurl重新编译安装
pip3 uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
pip install pycurl==7.43.0.3 --compile --no-cache-dir
但是我并没解决问题,用python3.8卸载重装不行,用python3.5卸载重装也不行,用python2.7.9也不行。最后用了python3.6可以了。
3.phantomjs not found
去官网下载一个phantomjs放到本地目录,添加到export PATH里就行了。
4.it's not the same object as pyspider.run.cli
用python2.7重新编译pycurl之后出的这个问题,
根据网上乱七八糟的方法执行了下面两个命令就出的这个问题。
python -m pip install wsgidav==2.4.1
python -m pip install werkzeug==0.16.1
因为别人写的博客是很久以前的,现在设置版本匹配不上是必然的。尤其是0.16.1根本装不上。
换成python3.6之后就没这问题了。
5. ImportError: cannot import name 'DispatcherMiddleware'
DispatcherMiddleware这个类所在的文件改名字了,修改代码把类名from和import写对就行了。
同样引起的问题还有TypeError: Can't instantiate abstract class ScriptProvider with abstract methods get_resource_inst
6. PySpider HTTP 599: SSL certificate problem错误的解决方法
添加validate_cert=False
self.crawl(url,callback=method_name,validate_cert=False)
参考网址:
https://blog.csdn.net/unicorntatata/article/details/122489906
https://www.cnblogs.com/leigepython/p/11984135.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
2020-03-07 小程序对接支付的全流程