We help IT Professionals succeed at work.

Exception has occured: ModuleNotFoundError in Python under Visual Studio Code

2,416 Views
Last Modified: 2018-11-09
Using:
  • Microsoft Visual Code 1.28.2 x64
  • Python 3.7

I've the smallest code ever
import ldap
print (ldap.__version__)

Open in new window


And i'm getting the error:
  • Exception has occured: ModuleNotFoundError
  • "No module named 'ldap'

I've installed the Wheel found on Christoph Gohlke web site.
using this command: pip install .\python_ldap-3.1.0-cp37-cp37m-win32.whl

I've checked the dependencies as shown here:
Capture.PNG
What am i missing?

Because when i run the following command in terminal, i'm getting "3.1.0" which mean that it can find the ldap module.
python -c "import ldap;print (ldap.__version__)"

Thanks a lot for your help
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Here's the result:
D:\USERS\Christian\Anaconda3\python.exe sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)

Author

Commented:
Apparently it's not using my Python 3.7 but the one that come with Anaconda.  I've followed the instructions "Select a Python Interpreter" from This website, and now it work.

Thanks for pointing me that.

When i type "Python <something>" in terminal window, it's not using that Anaconda, but the one it find in my path (3.7).  That's why it was giving a different result