win10使用pip安装pytorch,在pycharm中import torch失败的解决方法

    科技2026-04-10  8

    网上好多用conda装的,我使用pip在官网上已经装好了,cmd窗口下可以正常导入,使用官网的测试案例也可以正常运行

    from __future__ import print_function import torch x = torch.rand(5, 3) print(x)

    但是在pycharm中import torch会失败: 只需将解释器更改为Python3.6(没有的装一个3.6,3.8很多没适配)即可: 至于为啥cmd都行而pycharm不行,这个可能是pycharm本身的运行机制?不太清楚

    Processed: 0.010, SQL: 9