Pycharm Console 使用conda配置的Python环境时import报错解决

Pycharm Console 使用conda配置的Python环境时import报错解决

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;

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

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Philo`

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值