linux环境使用pip下载python包

微信公众号:WELTest

linux上pip源配置

切换到对应用户,创建.pip目录。下面以root用为例:

[root@localhost ~]# mkdir ~/.pip

在~/.pip目录下创建文件pip.conf:

[root@localhost ~]# cd  ~/.pip
[root@localhost .pip]# touch pip.conf

编辑文件pip.conf,如下信息:

[global]
index = http://pypi.tuna.tsinghua.edu.cn/
index-url = http://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
timeout = 6000

至此linux上pip源配置完毕。

pip下载指定安装包
准备requirement.txt文件

给出示例文件内容为:

protobuf>=3.6.1
absl-py>=0.7.0
keras-applications>=1.0.8
tensorflow-estimator<2.1.0,>=2.0.0
termcolor>=1.1.0
grpcio>=1.8.6
google-pasta>=0.1.6
astor>=0.6.0
opt-einsum>=2.3.2
wrapt>=1.11.1
tensorboard<2.1.0,>=2.0.0
numpy<2.0,>=1.16.0
google-auth-oauthlib<0.5,>=0.4.1
requests-oauthlib>=0.7.0
oauthlib>=3.0.0
升级pip版本

如果系统提示pip版本过低,执行命令升级:

pip install --upgrade pip

执行上述命令如提示:--trusted-host,调整命令为:

pip install --upgrade pip --trusted-host pypi.tuna.tsinghua.edu.cn
下载python包

常用命令是:

pip download  -d ./tensorflow -r requirement.txt

-d:指定存放下载包路径、-r:指定请求文件

下载不同平台的python包,下面给出命令集合:

windows_x86_64:

pip download --no-deps --platform windows_x86_64 --abi none -d ./tensorflow -r requirement.txt

macosx_10_10_x86_64:

pip download --no-deps --platform macosx_10_10_x86_64 --abi none -d ./tensorflow -r requirement.txt

linux_x86_64:

pip download --no-deps --platform linux_x86_64 --abi none -d ./tensorflow -r requirement.txt
any:
pip download --no-deps --platform any --abi none -d ./tensorflow -r requirement.txt

上述命令:

–no-deps:不安装依赖包选项

–platform:安装包使用平台。默认值为当前运行系统所属平台。

–abi:指定带有python abi的安装包。如pypy_41等。通常与–impementation、–platform、–python-version选项结合使用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

WEL测试

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

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

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

打赏作者

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

抵扣说明:

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

余额充值