gpt4 book ai didi

python - 尽管安装了 anaconda 解释器和 torch ,但无法在 vscode 中导入 torch

转载 作者:行者123 更新时间:2023-12-05 04:59:20 27 4
gpt4 key购买 nike

我同时安装了 python38,37 和 anaconda,操作系统 - win10,x64。

我无法在 py38,37 中安装 torch - 但在 anaconda 中安装了它。

系统环境变量“路径”有:

  • C:\python38\Scripts\
  • C:\python38\
  • C:\python37\Scripts\
  • C:\python37\
  • C:\anaconda3\
  • C:\anaconda3\Scripts

在 vscode 中,尽管我选择了解释器作为 Python 3.8.3 base-conda

enter image description here

我仍然无法导入手电筒。但是在使用 jupyter notebook 时,我可以导入 torch:

import torch
print(torch.__path__)

['C:\\anaconda3\\lib\\site-packages\\torch']

如何在vs code中导入torch并选择合适的解释器?

最佳答案

当我们导入模块时,我们需要在当前选择的环境中安装需要的模块。( Python environments .)

我使用以下语句将其安装在基础 conda 环境中:

conda install pytorch torchvision -c pytorch

enter image description here

我们需要注意Jupyter Notebook中选择的内核:

enter image description here

关于python - 尽管安装了 anaconda 解释器和 torch ,但无法在 vscode 中导入 torch ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63548665/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com