【问题标题】:torch module not found in jupyter notebook在 jupyter notebook 中找不到 torch 模块
【发布时间】:2023-01-07 03:12:05
【问题描述】:

我正在尝试在 jupyter notebook python 文件中导入 torch 并收到此错误:

ModuleNotFoundError: No module named 'torch'

我也将它安装在创建的环境中:

(pytorch_project) C:\Users\user>python
Python 3.7.15 (default, Nov 24 2022, 18:44:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>>

我怎样才能让它在 jupyter notebook 中也能工作?

【问题讨论】:

    标签: jupyter-notebook pytorch anaconda


    【解决方案1】:

    最可能的原因是您没有在 conda env 中安装 jupyter notebook。测试它

    where jupyter
    

    在你当前的环境中。

    如果路径不包含pytorch_project,你需要为你当前的conda环境安装jupyter:

    pip install jupyter
    

    然后,如果需要,重新激活 env。

    【讨论】:

      猜你喜欢
      • 2019-08-14
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 2018-04-26
      • 1970-01-01
      • 2021-09-19
      相关资源
      最近更新 更多