目录
一、离线安装python3.6.8
python版本下载地址1:https://www.python.org/downloads/
python版本下载地址2:https://www.python.org/ftp/python/3.6.8/
windows安装版:python-3.6.8-amd64.exe
windows绿色版:python-3.6.8-embed-amd64.zip
windows编译版:Python-3.6.8.tgz
二、依赖离线模块下载
python3.6依赖模块搜索地址:https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.6
python扩展包镜像网:https://www.lfd.uci.edu/~gohlke/pythonlibs/
selenium 中文文档:https://python-selenium-zh.readthedocs.io/zh_CN/latest/
三、爬虫离线模块安装
1、whl依赖包离线安装
python -m pip install --upgrade setuptools-51.0.0-py3-none-any.whl
python -m pip install --upgrade pip-20.3.3-py2.py3-none-any.whl
python -m pip install certifi-2020.12.5-py2.py3-none-any.whl
python -m pip install chardet-4.0.0-py2.py3-none-any.whl
python -m pip install idna-2.10-py2.py3-none-any.whl
python -m pip install urllib3-1.26.2-py2.py3-none-any.whl
python -m pip install requests-2.25.1-py2.py3-none-any.whl
python -m pip install lxml-4.6.2-cp36-cp36m-win_amd64.whl
python -m pip install selenium-3.141.0-py2.py3-none-any.whl
python -m pip install tesserocr-2.4.0-cp36-cp36m-win_amd64.whl
python -m pip install numpy-1.19.4-cp36-cp36m-win_amd64.whl
python -m pip install opencv_python-4.4.0.46-cp36-cp36m-win_amd64.whl
2、tar.gz依赖包离线安装
解压之后 cd 进入目录执行
python setup.py install
3、tesseract-ocr安装
Python tesserocr的安装教程:https://jingyan.baidu.com/article/6b18230972e3e6fb59e15909.html
(1)安装时选择多语言数据下载
(2)将 Tesseract-OCR 添加到环境变量
(3)安装成功之后需要将 Tesseract-OCR 根目录下的 tessdata 文件夹复制到 Python 根目录下,否则会出现报错
RuntimeError: Failed to init API, possibly an invalid tessdata path: D:\Python\Python36\Python368\/tessdata/
(4)指定变量 tesseract_cmd 为 安装的 tesseract.exe 文件
from PIL import Image
import pytesseract
## 引用 pytesseract 模块需要手动修改 tesseract_cmd 变量的依赖地址
pytesseract.pytesseract.tesseract_cmd = r'D:\Python\install-depend\Tesseract-OCR\tesseract.exe'
四、浏览器驱动下载安装
模拟浏览器 | 查看版本 | 镜像地址 | 驱动下载 |
谷歌浏览器 | chrome://version/ | http://chromedriver.storage.googleapis.com/index.html http://npm.taobao.org/mirrors/chromedriver | chromedriver_win32.zip |
火狐浏览器 | about:support | geckodriver-v0.26.0-win64.zip | |
微软浏览器 | edge://version/ | https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ | edgedriver_win64.zip |
opera浏览器 | https://github.com/operasoftware/operachromiumdriver/releases | operadriver_win64.zip | |
IE浏览器 | 设置 - 关于IE | http://selenium-release.storage.googleapis.com/index.html | IEDriverServer_x64_3.9.0.zip |
PhantomJS | https://phantomjs.org/download.html https://bitbucket.org/ariya/phantomjs/downloads | phantomjs-2.1.1-windows.zip |
五、验证版本和依赖
python -V
// Python 3.6.8
python
import platform
platform.architecture()
// ('64bit', 'WindowsPE')
import requests
import lxml
import seleninm
from PIL import Image
import pytesseract
import tesserocr
import cv2 as cv