Pyspider安装及完美运行

324 阅读1分钟

安装环境

  • Window 11 的WSL2 Ubuntu22.4(uname -a:5.15.146.1-microsoft-standard-WSL2 2024 x86_64 x86_64 x86_64 GNU/Linux)
  • miniconda (platform : linux-64)
  • Python (Python 3.6.13)

安装步骤

  1. 安装miniconda:

官网 下载安装脚本,运行脚本 bash Miniconda3-latest-Linux-x86_64.sh,按照提示完成安装

  1. 创建python 3.6的环境
  • 配置conda镜像,加速包的下载:
  1. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

  2. conda config --set show_channel_urls yes

  3. conda create -n test python=3.6

  1. 安装pyspider

重点一pip install pyspider 提示安装pycurl错误,解决方案是使用apt安装 libcurl4-openssl-dev:sudo apt install libcurl4-openssl-dev

重点二:按照 阿里云镜像配置手册配置Ubuntu资源路径/etc/apt/sources.list

  1. 运行pyspider pyspider all
    • 运行异常一 : TypeError: Can't instantiate abstract class ScriptProvider with abstract methods get_resource_inst

    异常截图 解决方案:将WsgiDAV降级只2.4版本 pip install WsgiDAV==2.4

    • 运行异常二ImportError: cannot import name 'DispatcherMiddleware

    image.png

    解决方案:

    1.将Werkzeug降级至Werkzeug-0.16.4(该方案会引起其他异常,具体解决思路请参考)这里);

    2.将\home\peekya\miniconda3\envs\big\lib\python3.6\site-packages\pyspider\webui\app.py文件内的 from werkzeug.middleware.dispatcher import DispatcherMiddleware替换成 from werkzeug.middleware.dispatcher import DispatcherMiddleware image.png

    • 运行异常三(可以不解决哦):RequestsDependencyWarning: urllib3 (1.26.18) or chardet (5.0.0)/charset_normalizer (2.0.12) doesn't match a supported version!

    image.png 解决方案:chardet降级至5.0版本 pip install chardet 5.0.0

正常运行效果展示

image.png

图中提示我的phantomjs未安装,自行官网下载即可

image.png