Skip to main content
Post Undeleted by Vishal Kamlapure
deleted 161 characters in body
Source Link

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/')

Hi check out this method :

from pymongo import MongoClient
client = MongoClient()

The above code will connect on the default host and port. We can also specify the host and port explicitly, as follows:

client = MongoClient('localhost', 27017)

Or use the MongoDB URI format:

client = MongoClient('mongodb://localhost:27017/')

I think you named your file same as module name i.e, pymongo.py. Change it to something else and that should work for you.

Also delete the pymongo.pyc file if one was created next to it.

Post Deleted by Vishal Kamlapure
Source Link

Hi check out this method :

from pymongo import MongoClient
client = MongoClient()

The above code will connect on the default host and port. We can also specify the host and port explicitly, as follows:

client = MongoClient('localhost', 27017)

Or use the MongoDB URI format:

client = MongoClient('mongodb://localhost:27017/')