0
votes
import numpy

is not working. This started because I couldn't get PyQt5 to work on my home computer. In the Spyder IDE, I can import modules and get everything working fine, but in VS Code, I can't import basic modules. I'm on Windows 10 with Python 3.7. I've Googled a lot and have tried these:

  1. Uninstall Anaconda and VS Code, and reinstall both
  2. In VS Code, press Ctrl+Shift+P, Select Interpreter, and select Python 3.7.1 64-bit ('base':conda), ~\Anaconda3\python.exe
  3. I saw on another similar question that python3.dll may be missing from one of my Anaconda directories, but it is indeed there.
  4. Add environment variable to PATH by going to System Properties > Advanced tab > Environment Variables... > under System Path, Edit, New > C:\Users\myname\Anaconda3\Scripts

Once I did #4 above, the new error message in VS Code when importing numpy is DLL load failed: The specified module could not be found. And in the terminal, I see: The term 'conda' is not recognized as the name of the cmdlet, ...

One thing I notice is in a Python prompt (not Anaconda) I type:

import sys
print(sys.version)

The output is 3.7.2, while in VS Code, the Select Interpreter (see above #2) says Python 3.7.1. Not sure if this is important.

Any help? Everything works on my work computer fine, but it's just my home computer that is being difficult.

2
Can you try help("modules") in both a shell and in a script within vs code and compare the list. It seems like you are using two different python installations. Do you have Python installed outside of Anaconda? - AlexNe
I do have Python installed outside of Anaconda. Is there a good reason to delete that version? I have the same dual installation setup at work where everything works fine. - maxutil
It should be fine, but my guess is that's why the versions are different. I guess you could install numpy via anaconda if it is not already and try again. And please check your modules with help("modules")...and oh. Having used both Anaconda and VSC imo Anaconda doesnt bring much functionality that is worth the hassle. - AlexNe

2 Answers

0
votes

What ended up working for me is downgrading my Python installation from 3.7.1 to 3.6.4 with:

conda install python=3.6.4

Hope this helps someone out there.

0
votes

On another question for the same problem, there was a suggestion that worked for me. Put this on the variable path.

C:\Users\<Your user name>\Anaconda3\Library\bin

credit to user1024.