Hi check out this methodI think you named your file same as module name i.e, :
from pymongo import MongoClient
client = MongoClient()
The above code will connect on the default host and portpymongo.py. We can also specify the hostChange it to something else and port explicitly, as follows:that should work for you.
client = MongoClient('localhost', 27017)
Or useAlso delete the MongoDB URI format:pymongo.pyc file if one was created next to it.
client = MongoClient('mongodb://localhost:27017/')