简体   繁体   中英

Visual Studio Code, not seeing pymongo 'ModuleNotFoundError' installed pymongo using pip. Why does it not see pymongo?

I'm in a software development program. One of my classes wants us to use Visual Studio Code, specifically to work with Python and MongoDB. For this assignment we are supposed to run these two lines in a command prompt,

pip install pymongo
pip install pymongo[srv]

I did that and they were both installed. After that I'm supposed to do this:

Import MongoClient
from pymongo import MongoClient

Create a variable named url and assign it the connection string value you copied from MongoDB Atlas.

url = “”;

Create a variable named client and call the MongoClient passing-in the url variable.

client = MongoClient(url)

and it goes on. The problem I have been having is when I try to run the code I just explained, Visual Studio Code says ModuleNotFoundError: No module named 'pymongo'... I have read a lot on the internet about similar problems, but none of the solutions have worked for me.

I tried uninstalling Python and then reinstalling it, to no avail.

Did you try to run your code from a cli? Did it work? Maybe your VSC is using a different python environment in which pymongo isn't installed:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM