0

I am switching the IDEs (from Spyder to VS Code). Howeve, the script that I used to run in Spyder throws an error when I run it on VS Code :

Error picture

I followed these solutions SO1, SO2, SO3: tried to launch the VS code by Anaconda prompt or uninstall and reinstall numpy and reran the script but the same error was still popped up.

Anyone can help me ?

Here is the output of conda env list : Picture

mht
  • 133
  • 1
  • 2
  • 9
  • There should be an `activate.ps1` script, try running that instead of just `activate`. Might help. – Diptangsu Goswami May 22 '21 at 15:46
  • Upgrade `numpy`; recent version is `1.20.3`… – JosefZ May 22 '21 at 15:56
  • @Diptangsu Goswami : What does that mean ? Sorry, I am new to python. – mht May 22 '21 at 16:06
  • @JosefZ I use pip install numpy --upgrade but it said that my numpy version (1.19.2) is the newest one. – mht May 22 '21 at 16:09
  • @JosefZ I think `1.20` is not yet available via conda – user_na May 22 '21 at 16:20
  • run `conda env list` and show us the output. You need to be activating one of the available envs that has numpy installed in it. I'd guess that the env you're using is `base`. Considering my assumption is correct, just run `conda activate base`. Then, run your code in the same terminal. – Diptangsu Goswami May 22 '21 at 20:39
  • @DiptangsuGoswami : you can find the output in the 2nd image. I ran conda activate base also and reran the code however it still throws that error. – mht May 22 '21 at 20:58

1 Answers1

0

It's because you haven't activated the conda environment.

You can find it does not have the environment name before the

PS D:\Desktop\work...

It should be like:

(base)PS D:\Desktop\work...

You can find it in your second picture.

If you haven't activated the conda environment, it will cause the mkl problem.

User Warning:mkl-service package failed to import...

Importing the numpy C-extension failed.

It's not a problem of you haven't installed the numpy package.

Try to run conda init command in any terminal. It maybe helpful.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13