解决pytorch明明已经安装好了但是import时报错ModuleNotFoundError: No module named ‘torch‘

问题:

按照b站一些up主的方法来安装,结果运行时却告诉我:报错ModuleNotFoundError: No module named ‘torch‘ 可是我明明已经装了torch

安装教程参考的是(https://www.bilibili.com/video/BV1o3411V7Zz/?spm_id_from=333.880.my_history.page.click&vd_source=ad813e1004be679f01f964a5bda10dd8)

解决:

后来看了一些人的经验,总算没再有这个问题,解决如下:

  • 按照上面那个教程按照anaconda,注意一定要 install for just me!just me!just me! 这样之后才会有 自己添加路径不用人为添加的选项,操作会简单些。
  • 按照该up主在base里建了其他环境并在里面安装,但结果是No module named ‘torch‘ ,于是后来在base里直接复制粘贴清华源,然后把pytorch网站上响应的语句复制粘贴,最后成功
  • `conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
    conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  • conda config –set show_channel_urls yes
    `
    我用了cpu

    物联沃分享整理
    物联沃-IOTWORD物联网 » 解决pytorch明明已经安装好了但是import时报错ModuleNotFoundError: No module named ‘torch‘

    发表评论