"Dnspython module must be installed" error though already done so

I am in Chapter 1 of M220P and am attempting to setup the environment necessary to run my project. I am using a Notebook in Jupyter.

The command I am running is as follows:
client = pymongo.MongoClient(uri)

The error I get is:
The “dnspython” module must be installed to use mongodb+srv:// URIs. To fix this error install pymongo with the srv extra:

I tried this along with the solutions given in this discussion but I cannot get the solution to work. I still get the same error. I am running Windows 10 with Python 3.9.6. Please advise.

Hi @Ganesha_Muthkumaran,

This is what you need: pip install pymongo[srv]

Make sure it’s correctly installed in the Virtual Env of your Jupyter notebook and not in the global python env you have on your machine.

Cheers,
Maxime.

2 Likes