pymongo - "dnspython" module must be installed to use mongodb+srv:// URIs

Solution 1:

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 suggested by @lukrebs, add quotes for ZSH:

pip3 install 'pymongo[srv]'

Solution 2:

I solved this problem with:

$ python -m pip install pymongo[srv]

Solution 3:

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.

Solution 4:

In requirements.txt, replace pymongo with pymongo[tls,srv], as mentioned here.