linux下python安装pip_linux环境使用pip下载python包

本文介绍了如何在Linux系统中配置pip源,详细步骤包括创建.pip目录、编辑pip.conf文件,并提供了切换到清华大学镜像源的配置。此外,文章还讲解了如何准备requirement.txt文件,升级pip,以及使用不同命令下载特定平台的Python包。
摘要由CSDN通过智能技术生成

微信公众号: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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值