pymongo - mongodb+srv “dnspython must be installed

2019-07-22 13:21发布

问题:

I am trying to connect MongoDB from Atlas But I encountered "dnspython must be installed error".

My mongo uri (mockup): mongodb+srv://abc:123@something.something.com/admin?retryWrites=True

My pymongo version: 3.6.1 I have installed dnspython and done import dns

Still, I am getting the error "dnspython module must be installed to use mongodb+srv:// URI"

Can anybody help?

回答1:

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.



回答2:

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)



回答3:

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