C/C++教程

pyspider macbook安装问题汇总

本文主要是介绍pyspider macbook安装问题汇总,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录
  • 1. async问题
  • 2. pycurl: libcurl link-time ssl backends (secure-transport, openssl) do not include compile-time ssl b
  • 3.phantomjs not found
  • 4.it's not the same object as pyspider.run.cli
  • 5. ImportError: cannot import name 'DispatcherMiddleware'
  • 6. PySpider HTTP 599: SSL certificate problem错误的解决方法

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都改个名就行了。

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

这篇关于pyspider macbook安装问题汇总的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!