linux批量安装pip download下载的whl和tar.gz的bash脚本
脚本
python_exe="$(dirname "$1")/$(basename "$1")/bin/python"
pip_exe="$(dirname "$1")/$(basename "$1")/bin/pip"
package_dir="$(dirname "$2")/$(basename "$2")"
for file in $package_dir/*.whl ]; do
$pip_exe install "$file" --no-deps
if [ $? != "0" ]; then
echo "Some error happend !"
exit 1
fi
done
if [ -f $package_dir/*.tar.gz ]; then
for file in `find $package_dir -name *.tar.gz`; do
cd $package_dir
tar -zxvf "$file" -C /tmp -k
cd /tmp/`basename "$file" .tar.gz`
$python_exe setup.py install
if [ $? != "0" ]; then
echo "Some error happend !"
exit 1
done
fi
echo "Success finished packages install !"
执行命令
假如上述脚本的位置位于/opt/py_packages_install.sh
linxu执行:sh /opt/py_packages_install.sh 需要安装包的环境路径 pip下载的包的目录
- 提示:
需要安装包的虚拟环境路径,如:/usr/local/python3_venvs/my_project
pip下载的包的目录,如:/usr/local/src/packages

浙公网安备 33010602011771号