Trying to connect a Colab Notebook to a MongoDB on Atlas.
from pymongo import MongoClient
uri = "mongodb+srv://MYUSERNAME:[email protected]/test"
client = MongoClient(uri)
I am getting a CongfigurationError:
"dnspython" module must be installed to use mongodb+srv:// URIs.
I installed the module.
pip install dnspython
Got the message back
Requirement already satisfied: dnspython in /usr/local/lib/python3.6/dist-packages (1.16.0)
Do not know what is wrong.
This worked a few days ago with another colab notebook (and another database).
Here is the entire error message:
ConfigurationError Traceback (most recent call last)
<ipython-input-30-a6c89e14e64f> in <module>()
----> 1 client = MongoClient(uri)
1 frames
/usr/local/lib/python3.6/dist-packages/pymongo/mongo_client.py in __init__(self, host, port, document_class, tz_aware, connect, type_registry, **kwargs)
522 for entity in host:
523 if "://" in entity:
--> 524 res = uri_parser.parse_uri(entity, port, warn=True)
525 seeds.update(res["nodelist"])
526 username = res["username"] or username
/usr/local/lib/python3.6/dist-packages/pymongo/uri_parser.py in parse_uri(uri, default_port, validate, warn)
316 elif uri.startswith(SRV_SCHEME):
317 if not _HAVE_DNSPYTHON:
--> 318 raise ConfigurationError('The "dnspython" module must be '
319 'installed to use mongodb+srv:// URIs')
320 is_srv = True
ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs
You have to restart runtime to have the changes take effect:
!pip install dnspython
Runtime -> Restart runtime...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With