Exception has occured: ModuleNotFoundError in Python under Visual Studio Code

Christian de Bellefeuille
Christian de Bellefeuille used Ask the Experts™
  • 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:
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
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I'm not using visual studio code, but I guess, that visual studio code is not using the version of python as your command line prompt.

What I suggest.

Please type

python -c "import sys  ; print(sys.executable, sys.version_info)"
in your cmd prompt

then insert two lines as first lines in your "smallest script ever"
import sys
print(sys.executable, sys.version_info)

Open in new window

end post results  here


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


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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial