Exception has occured: ModuleNotFoundError in Python under Visual Studio Code

  • 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
LVL 10
Christian de BellefeuilleProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Christian de BellefeuilleProgrammerAuthor Commented:
Here's the result:
D:\USERS\Christian\Anaconda3\python.exe sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
Christian de BellefeuilleProgrammerAuthor 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.