python安装torch时遇到 ERROR: Command errored out with exit status 1:

时间:2024-03-21 14:20:54

python安装torch时遇到 ERROR: Command errored out with exit status 1:

之前用pycharm运行github上一个模型时,遇到了import torch失败的问题,而且用pip安装失败。我根据网上的教程我的博客里有详细教程用Anaconda安装了torch,问题确实得到了解决,torch安装成功。紧接着再运行模型时就发现了更多的错误,研究了很久发现是之前安装的torch版本有问题。再用pip安装就出现了上面的错误。
python安装torch时遇到 ERROR: Command errored out with exit status 1:看到出现了这么多乱七八糟的东西就很慌,找了一下午,终于找到了最终的解决方法:

查看自己的python版本

python安装torch时遇到 ERROR: Command errored out with exit status 1:
点开自己的pycharm的控制台,就能找到自己安装的python版本以及位数,像我的python就是3.7.3的32位的。

下载torch

根据我们刚刚查的python版本与位数去torch官网下载对应版本的torch。

python安装torch时遇到 ERROR: Command errored out with exit status 1:这里可以选择自己需要的版本,我们直接复制Run this Command后面的命令回pycharm命令行即可下载适合自己电脑版本的torch。不过在pycharm中下载容易中断,我们可以复制命令行提示的链接直接网上下载,会快很多。
python安装torch时遇到 ERROR: Command errored out with exit status 1:
注:cp37表示python版本是3.7的
win amd64表示python是64位的。这里有一个疑问,我的python是32位的, 但是系统下载的是64位,不过能用就行啦。

安装torch

1、下载了适合的torch后,用cmd进入torch所在的文件夹。
python安装torch时遇到 ERROR: Command errored out with exit status 1:
2、输入pip install torch-1.4.0+cpu-cp37-cp37m-win_amd64.whl完成安装就可以啦。
python安装torch时遇到 ERROR: Command errored out with exit status 1:
最终,模型得以运行,希望对大家有所帮助。