当前位置:   article > 正文

pycharm2024 1.4版本 配置 conda 环境配置_pycharm 2024.1.4

pycharm 2024.1.4

运行代码

  1. import torch
  2. a = torch.cuda.is_available()
  3. print(a)

配置报错

  1. Traceback (most recent call last):
  2. File "D:\File\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3457, in run_code
  3. exec(code_obj, self.user_global_ns, self.user_ns)
  4. File "<ipython-input-2-191f6205abea>", line 1, in <module>
  5. runfile('D:\\File\\Pycharm\\Projects\\pythonProject1\\main.py', wdir='D:\\File\\Pycharm\\Projects\\pythonProject1')
  6. File "D:\File\Pycharm\PyCharm 2024.1.4\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
  7. pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
  8. File "D:\File\Pycharm\PyCharm 2024.1.4\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
  9. exec(compile(contents+"\n", file, 'exec'), glob, loc)
  10. File "D:\File\Pycharm\Projects\pythonProject1\main.py", line 1, in <module>
  11. import torch
  12. File "D:\File\Pycharm\PyCharm 2024.1.4\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
  13. module = self._system_import(name, *args, **kwargs)
  14. ModuleNotFoundError: No module named 'torch'

这里是创建文件时路径问题

在Anaconda Prompt (Anaconda)中输入命令行

conda env list

查看需要调用的环境名

在pycharm中配置环境后运行代码

以下情况表示配置成功

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号