pip download制作离线安装

由于公司的服务器处于与外网隔离的状态,安装第三方包比较麻烦,故写此文章,仅供参考。

1. 在本机虚拟机(物理机)联网执行

直接执行:pip download -d /home/pkgs tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
或者将需要安装的软件写入requirement.txt 执行pip download -d /home/pkgs -r requirement.txt

以在公司服务器上安装tensorflow等开发环境为例(离线安装):

#!/usr/bin/bash

echo "下载前的准备..."
username="username"
cd /home/$usernme
mkdir -p /home/$usernme/pkgs
cat > requirement.txt <<"EOF"
tensorflow==2.2.0
scikit-image==0.15.0
scikit-learn==0.24.2
opencv-python==4.5.2.52
numpy
pandas
requests
flask
EOF

echo "下载中..."
pip download \
-d /home/$usernme/pkgs \
-r requirement.txt \
-i https://pypi.tuna.tsinghua.edu.cn/simple \
--proxy=http://192.168.110.111

echo "打包压缩文件..."
tar -zcvf tensorflow_and_other_file.tar.gz pkgs

二、离线安装

pip install --no-index --find-links=/home/pkgs tensorflow
pip install --no-index --find-links=/home/pkgs -r requirements.txt

鸣谢:
https://www.cnblogs.com/michael-xiang/p/5690746.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SongpingWang

你的鼓励是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值