I am unable to do this:
from pymongo import MongoClient
I get:
>>> import pymongo
>>> from pymongo import
If you used pymongo.Connection and encountered error, you should know that after the new updates, you should use pymongo.MongoClient instead. I had this issue so hopefully this will be helpful to someone else.
Make sure your python source file is not called pymongo.py
This problem may occur if you have multiple .py programs in the current working directory. Deleting them solved my error. I am not sure of the reason though.
According to docs, MongoClient
was introduced in version 2.4. As you installed pymongo
from your distribution repository, it's quite possible it's not the most recent version. Try installing it via PiP (remove the one you have installed first):
pip install pymongo
Worked for me for conda env
pip uninstall pymongo
then
pip install pymongo
If you had named your script pymongo.py, which masks the pymongo module from which you are importing.
Rename your script to something else like xyz.py (and delete the pymongo.pyc file if one was created next to it).