使用 pip 下载安装某些第三方库,是一件很痛苦的事情,下载速度很慢。一旦下载超时,下载会被中止,需要重新下载。
本人用Python批量爬取https://www.lfd.uci.edu/~gohlke/pythonlibs/上的第三方库(二进制.whl文件)
脚本是sh脚本,运行(单个下载)
bash xxxxx.sh package1
package1是你要下载的库名
多个下载是代码:
bash xxxxx.sh package1 package2
sh代码脚本
#!/bin/bash
# Create a directory to store the wheels
mkdir -p pypi_wheels
# Loop through each specified package and download the wheel
for package in "$@"; do
echo "Downloading $package..."
pip download --no-cache-dir --disable-pip-version-check -d pypi_wheels $package
done
echo "Download complete. Wheels are stored in 'pypi_wheels' directory."