admin管理员组文章数量:1666729
Pycharm Console 使用conda配置的Python环境时import报错解决
- 1、错误背景
- 2、错误原因
- 3、问题解决
- 3.1、py文件报错解决
- 3.2 .console 报错解决
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: 找不到指定的模块。
解决方法:
点击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;
结果显示:
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;
结果展示:
版权声明:本文标题:Pycharm Console 使用conda配置的Python环境时import报错解决 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1730076815a1221885.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论