I am trying to connect MongoDB from Atlas But I encountered:
dnspython must be installed error
My mongo uri (mo
In order to use mongo+srv protocol, you need to install pymongo-srv Launch this command to do it with python 3:
pip3 install pymongo[srv]
or this one for other versions:
pip install pymongo[srv]
And as @lukrebs suggested, for ZSH, add quotes:
pip3 install 'pymongo[srv]'
May be the protocol, your URI should start with:
mongo+srv instead of mongo+src
If it still not working please put a pip list with the versions of PyMongo and dnspython (and version of python that you are using)
In requirements.txt, replace pymongo
with pymongo[tls,srv]
, as mentioned here.
I would like to answer my own questions here. As I mentioned in the comment, the kernel of the jupyter notebook has to be restarted in order for the pymongo to take effect of the loaded dnspython
.
you can use mongo://
instead of mongodb+srv://
I solved this problem with:
$ python -m pip install pymongo[srv]