pymongo - mongodb+srv "dnspython must be installed" error

addicted picture addicted · Oct 22, 2018 · Viewed 33.8k times · Source

I am trying to connect MongoDB from Atlas But I encountered:

dnspython must be installed error

My mongo uri (mockup): mongodb+srv://abc:[email protected]/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

Answer

veben picture veben · Sep 12, 2019

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]'