pymongo - mongodb+srv “dnspython must be installed” error

爷,独闯天下 提交于 2019-12-08 15:21:05

问题


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


回答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]



回答2:


I solved this problem with:

$ python -m pip install pymongo[srv]




回答3:


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




回答4:


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)




回答5:


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.




回答6:


you can use mongo:// instead of mongodb+srv://



来源:https://stackoverflow.com/questions/52930341/pymongo-mongodbsrv-dnspython-must-be-installed-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!