When VS code imported Cv2, an error ImportError: numpy.core.multiarray failed to import; There are no mistakes in using the Spyder

The following error occurs when programming in VsCode and using anaconda’s virtual environment as the interpreter to import Cv2

ImportError: numpy.core.multiarray failed to import

After checking the trial, it was found that:

    I use on spyder without this error; Also used after trying to update numPY; And the python interpreter in the lower left corner is the right choice;

It turned out that the reason might be that vs Code was not started correctly and the Anaconda environment might not have been activated.
In the Anaconda Prompt, the following is executed in sequence

conda activate env_name
cd workDir
code .

So now it’s activated and the import is correct.
In addition, try to directly open VS Code, and then open python working directory in the File-Open folder.
Also note this error. The environment of Vscode is correct, but the terminal does not activate the environment. This can be determined by checking the contents of the prefix brackets.

Read More: