pip安装‘torch‘出现PackageNotFoundError报错解决办法

原文链接

1.虚拟环境安装:

若安装失败,可能权限不够,需要在根用户下安装:进入根用户

2.安装torch:

pip install torch

或者使用:

conda install torch

3.若出现报错PackageNotFoundError:

Fetching package metadata ...........

PackageNotFoundError: Package missing in current linux-64 channels:
  - torch

Close matches found; did you mean one of these?

    torch: pytorch, libtorch

可以使用下面的指令来查找我们想要安装的torch包:

anaconda search -t conda torch

如上图所示。

(1)在Linux下,我们找到了一个可用的torch包,名为Reinier/pytorch 。

接着,我们使用show指令来查看该包的详细情况:

anaconda show Reinier/pytorch

根据提示,我们使用下面的指令install这个包:

conda install --channel https://conda.anaconda.org/Reinier pytorch

(2)window下,我们找到了一个可用的torch包,名为mwcraig/boost-vpython 。

接着,我们使用show指令来查看该包的详细情况:

anaconda show mwcraig/boost-vpython

根据提示,我们使用下面的指令install这个包:

conda install --channel https://conda.anaconda.org/mwcraig boost-vpython

4.若报错Requirement already satisfied:

Requirement already satisfied: torch in /home/snowstorm/.conda/envs/snowstorm/lib/python3.6/site-packages (0.1)

应加上更新参数:

pip install torch --upgrade

5.若报错Requirement already up-to-date:

Requirement already up-to-date: torch in /home/snowstorm/.conda/envs/snowstorm/lib/python3.6/site-packages (0.1)

是因为在下载torch包的时候默认使用了一个已经废弃的下载地址。

1.删除/home/snowstorm/.conda/envs/snowstorm/lib/python3.6/site-packages (0.1)下的torch文件 

2.更改更新命令,加入下载镜像地址:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch

常用的镜像网站:

清华大学:Simple Index

中国科学技术大学:Simple Index

阿里云:Simple Index

豆瓣 :Simple Index

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/

6.若报错Could not install packages due to an EnvironmentError:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/anaconda3/lib/python3.7/site-packages/llvmlite-0.28.0.dist-info'
Consider using the `--user` option or check the permissions.


需要加上--user:pip install <module>  改为 pip install --user <module>

pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple torch

学习更多编程知识,请关注我的公众号:

代码的路

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

代码的路

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

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

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

打赏作者

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

抵扣说明:

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

余额充值