After using Anconda to create the environment, ImportError: DLL load failed appears in the Pycharm running code: the solution to the specified module cannot be found

Table of contents

1. Problem description

2. Problem analysis

3. Solutions

1. Problem description

I recently wrote code with pycharm and encountered this error:

 2. Problem analysis

Since I am using the virtual environment created by Anaconda, the configuration of the relevant pycharm project has been completed when the project was first created, and this error occurred long after the project was created . I did the following checks:

(1) Project setting check function package

This is consistent with the package of the conda virtual environment (the function package check method of the conda virtual environment: enter activate <virtual environment name> in the cmd window, enter the conda virtual environment, and use the pip list command to view).

(2) Pycharm's interrupt window inspection function package

The list of feature packages here is inconsistent with the virtual environment created by conda . I didn't check it carefully, but I guess it is consistent with the feature packages of Anaconda's main directory Lib>site-packages, not the feature packages in the virtual environment created by myself .

3. Solutions

After trying the methods on many posts on the Internet, but none of them solved the problem, I realized through the above verification that it was an interpreter problem. Pycharm can't correctly locate the function package needed in the code through the interpreter, whether it comes from the package under \Lib\site-packages of Anaconda, or the \Lib\site-packages of the environment created by Anaconda, I set the interpreter of the project by resetting , the problem is solved.

First enter this interface through Settings>Project>Python Interpreter, and then select Add Interpreter

 Choose to add the path of the Python interpreter that your project depends on intact , that is, add it again without any modification .

Then select the name of the newly added interpreter here, because it is exactly the same before and after, so there will be one more (number) after the name 

The problem has been solved (you can see that the interpreter path used here is exactly the same as the picture that encountered the problem at the beginning) , although I don't know what's going on.

4. Supplementary instructions

I used this method to solve this problem, but after a while, the same error will appear again, so I followed the same steps to solve this problem, and I can't find the problem at present...

Guess you like

Origin blog.csdn.net/Er_Studying_Bai/article/details/127360690