安装环境
- 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)
安装步骤
- 安装miniconda:
从官网 下载安装脚本,运行脚本
bash Miniconda3-latest-Linux-x86_64.sh,按照提示完成安装
- 创建python 3.6的环境
- 配置conda镜像,加速包的下载:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda create -n test python=3.6
- 安装pyspider
重点一:
pip install pyspider提示安装pycurl错误,解决方案是使用apt安装 libcurl4-openssl-dev:sudo apt install libcurl4-openssl-dev重点二:按照 阿里云镜像配置手册配置Ubuntu资源路径
/etc/apt/sources.list
- 运行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
解决方案:
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- 运行异常三(可以不解决哦):
RequestsDependencyWarning: urllib3 (1.26.18) or chardet (5.0.0)/charset_normalizer (2.0.12) doesn't match a supported version!
解决方案:chardet降级至5.0版本
pip install chardet 5.0.0 - 运行异常一 :
正常运行效果展示
图中提示我的phantomjs未安装,自行官网下载即可