says dnspython isn't installed with mongodb but it is

255 Views Asked by At

I wanna import my database or whatever, I have an actual username and password but changed them

import dns
import pymongo 
from pymongo import MongoClient 
cluster = MongoClient('mongodb+srv://username:[email protected]/myFirstDatabase?retryWrites=true&w=majority')

I'm getting this error

ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs. To fix this error install pymongo with the srv extra:
 C:\Users\16308\AppData\Local\Programs\Python\Python39\python.exe -m pip install "pymongo[srv]"

I read on another thread to do this, nothing changed

PS C:\Users\16308> pip install pymongo[srv]
>>
Requirement already satisfied: pymongo[srv] in c:\users\16308\appdata\local\programs\python\python39\lib\site-packages (4.0.2)
Requirement already satisfied: dnspython<3.0.0,>=1.16.0 in c:\users\16308\appdata\local\programs\python\python39\lib\site-packages (from pymongo[srv]) (2.2.1)

Thanks for any help

Edit: Path code is

['c:\\Users\\16308\\Documents\\VSCPython', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39', '', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32\\lib', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\Pythonwin', 'C:\\Users\\16308\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\16308\\.ipython', 'C:\\Users\\16308\\AppData\\Roaming\\Python\\Python39\\site-packages']
1

There are 1 best solutions below

0
On

I've had this problem after updating my python installation. I had to reinstall the pymongo pip uninstall followed by a pip install