简体   繁体   English

pytorch 在 anaconda 提示符下运行,但在 python 空闲时不运行

[英]pytorch runs in anaconda prompt but not in python idle

I know this question might be stupid, but I couldn't find any help on the internet.我知道这个问题可能很愚蠢,但我在互联网上找不到任何帮助。 Recently I installed anaconda in my computer, it runs Windows 10 x64.最近我在我的电脑上安装了 anaconda,它运行 Windows 10 x64。 Then I used anaconda prompt to download and install pytorch for 3.6 python:然后我使用 anaconda 提示下载并安装 pytorch for 3.6 python:

conda install pytorch torchvision cuda100 -c pytorch

After the installation I verified in anaconda's prompt that pytorch is installed:安装后,我在 anaconda 的提示符中验证了 pytorch 已安装:

>>> Python
>>> Import torch
>>> torch.cuda.is_available()
True

I also checked conda list and indeed pytorch is installed in my machine.我还检查了 conda 列表,确实 pytorch 安装在我的机器上。 However, I write Python code in python 3.6.7 IDLE, not in anaconda prompt, so, whenever I try to import pytorch I get the message: However, I write Python code in python 3.6.7 IDLE, not in anaconda prompt, so, whenever I try to import pytorch I get the message:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pytorch
ModuleNotFoundError: No module named 'pytorch'

For some reason, Anacoda prompt recognizes pytorch, but not IDLE.出于某种原因,Anacoda 提示识别 pytorch,但不是 IDLE。 Is there any solution for this?有什么解决办法吗? Is there any way to import pytorch module to IDLE?有什么方法可以将 pytorch 模块导入 IDLE 吗? Thanks in advance.提前致谢。

I know this question might be stupid, but I couldn't find any help on the internet.我知道这个问题可能很愚蠢,但我在互联网上找不到任何帮助。 Recently I installed anaconda in my computer, it runs Windows 10 x64.最近我在我的电脑上安装了 anaconda,它运行 Windows 10 x64。 Then I used anaconda prompt to download and install pytorch for 3.6 python:然后我使用anaconda prompt下载并安装了3.6 python的pytorch:

conda install pytorch torchvision cuda100 -c pytorch

After the installation I verified in anaconda's prompt that pytorch is installed:安装后我在 anaconda 的提示中验证了 pytorch 已安装:

>>> Python
>>> Import torch
>>> torch.cuda.is_available()
True

I also checked conda list and indeed pytorch is installed in my machine.我还检查了 conda list,确实 pytorch 安装在我的机器上。 However, I write Python code in python 3.6.7 IDLE, not in anaconda prompt, so, whenever I try to import pytorch I get the message:但是,我在 python 3.6.7 IDLE 中编写 Python 代码,而不是在 anaconda 提示符下,因此,每当我尝试导入 pytorch 时,都会收到以下消息:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pytorch
ModuleNotFoundError: No module named 'pytorch'

For some reason, Anacoda prompt recognizes pytorch, but not IDLE.出于某种原因,Anacoda 提示识别 pytorch,但不能识别 IDLE。 Is there any solution for this?有什么解决办法吗? Is there any way to import pytorch module to IDLE?有什么方法可以将 pytorch 模块导入 IDLE? Thanks in advance.提前致谢。

did you type "import torch" in Anaconda prompt but "import py torch" in idle?您是否在 Anaconda 提示符中输入了“import torch”,但在空闲时输入了“import py torch”? if yes, that is simply the issue, so type "import torch" in any idle not如果是,这就是问题所在,所以在任何空闲时输入“import torch”而不是

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM