配置python环境、pip安装包的注意点

今天配置一个环境的包的时候,使用requirements.txt文件时遇到几个问题,记录一下,执行以下代码

pip install -r requirements.txt

要注意该文件的路径,可以把完整路径写入,这样避免报错找不到该文件

其次,在执行上述指令的时候,发生了类似如下的错误,而且在虚拟环境中找不到“我以为的安装好的包”,这是因为,在按照requirements.txt文件安装的时候,是按照先后顺序来的,如果有一个错误整个下载都会终止 ,所以一定要注意文件中的版本号是否正确

ERROR: Ignored the following versions that require a different python version: 1.16.0rc1 Requires-Python >=3.11; 1.6.2 Requires-Python >=3.7,<3.1
0; 1.6.3 Requires-Python >=3.7,<3.10; 1.7.0 Requires-Python >=3.7,<3.10; 1.7.1 Requires-Python >=3.7,<3.10; 2.3.0rc1 Requires-Python >=3.11; 3.5r
c0 Requires-Python >=3.11
ERROR: Could not find a version that satisfies the requirement torch==2.1.2+cu121 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0,
2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.5.0, 2.5.1, 2.6.0, 2.7.0)
ERROR: No matching distribution found for torch==2.1.2+cu121

为了下载的更快,我们可以选择在后边加上镜像地址,如:

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

 最后成功的界面:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值