问题
当你想安装pyppeteer下载chromium,但是遇到如下的问题:
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='npm.taobao.org', port=443): Max retries exceeded with url: /mirrors/chromium-browser-snapshots/Linux_x64/575458/chrome-linux.zip (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
是不是很崩溃?这里告诉你一个小小技巧,比网上大部分的答案,更可靠。
解决方案
- 编辑lib/python3.7/site-packages/pyppeteer/chromium_downloader.py 这个文件
因为我是python3.7版本,路径就是这个,其他版本请自行修改。
77 with urllib3.PoolManager() as http:
78 # Get data from url.
79 # set preload_content=False means using stream later.
80 data = http.request('GET', url, preload_content=False)
第77行改成
77 with urllib3.PoolManager(cert_reqs='CERT_NONE') as http:
78 # Get data from url.
79 # set preload_content=False means using stream later.
80 data = http.request('GET', url, preload_content=False)
- 再次执行安装
$ pyppeteer-install
[W:pyppeteer.chromium_downloader] start chromium download.
Download may take a few minutes.
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 106826418/106826418 [01:26<00:00, 1232939.52it/s]
[W:pyppeteer.chromium_downloader]
chromium download done.
[W:pyppeteer.chromium_downloader] chromium extracted to: /home/testerzhang/.local/share/pyppeteer/local-chromium/575458
是不是很简单。
网友评论