当前位置:   article > 正文

Pycharm Console 使用conda配置的Python环境时import报错解决_important: please read this for advice on how to s

important: please read this for advice on how to solve this issue! importing

1、错误背景

自己使用的conda创建的python,安装了Pytorch环境,在jupyter上可以正常使用,命令行也可以正常使用,但是用Pycharm创建新项目时,使用conda创建的Python环境,在正常的py文件中import时报错,而且控制台也是import报错。

2、错误原因

因为在命令行中没错,在Pycharm中使用错误,则可能还是环境没有配置好,它报错是找不到模块,即它的环境目录没有放入进去,解决方法如下

3、问题解决

3.1、py文件报错解决

报错形式:
在这里插入图片描述

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.6 from "D:\APP\Anaconda\envs\torch\python.exe"
  * The NumPy version is: "1.19.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed: 找不到指定的模块。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

解决方法:
点击Edit Configurations->Environment variables->文件图标->±>输入conda配置的Python环境路径相关参数:
参数是自己的Python环境,自己修改成自己的

D:\APP\Anaconda;
D:\APP\Anaconda\Library\mingw-w64\bin;
D:\APP\Anaconda\Library;
D:\APP\Anaconda\Lib\site-packages;
D:\APP\Anaconda\Scripts;
D:\APP\Anaconda\envs\torch\Library\bin;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
结果显示:
在这里插入图片描述

3.2 .console 报错解决

解决办法:
file->Settings->搜索Python Console->Environment variables->输入上面的参数:
参数是自己的Python环境,自己修改成自己的

D:\APP\Anaconda;
D:\APP\Anaconda\Library\mingw-w64\bin;
D:\APP\Anaconda\Library;
D:\APP\Anaconda\Lib\site-packages;
D:\APP\Anaconda\Scripts;
D:\APP\Anaconda\envs\torch\Library\bin;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

结果展示:
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/595779
推荐阅读
相关标签
  

闽ICP备14008679号