I am trying to connect to my MongoDB Cluster using the SRV scheme and I am encountering a problem while trying to connect. Below is the code I've tried
from motor import motor_asyncio
motor_client = motor_asyncio.AsyncIOMotorClient('mongodb+srv://<user>:<password>@examplecluster-ece7n.azure.mongodb.net/test?retryWrites=true&w=majority')
_db = self.motor_client.translations
_collection = _db.translations_collections
I have dnspython module installed but this is the error that still pops up:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/libneko/extras/superuser.py", line 176, in execute_in_session
result = await locals()["aexec"](ctx, ctx.bot)
File "<string>", line 4, in aexec
File "/usr/local/lib/python3.7/site-packages/motor/core.py", line 141, in __init__
delegate = self.__delegate_class__(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pymongo/mongo_client.py", line 524, in __init__
res = uri_parser.parse_uri(entity, port, warn=True)
File "/usr/local/lib/python3.7/site-packages/pymongo/uri_parser.py", line 318, in parse_uri
raise ConfigurationError('The "dnspython" module must be '
pymongo.errors.ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs
It should successfully connect to the cluster from what I expect and also, just two points to specify
- I installed dnspython AFTER the error popped up.
- It seems the problem is similar to this pymongo - mongodb+srv "dnspython must be installed" error but I am NOT using Jupyter Notebook.