I'm trying to connect to MongoDB from the pyCharm environment. I'm using python 3.8 and I installed pymongo, dnspython and dnspython3.
My settings for the project are:
My code is:
from pymongo import MongoClient
import argparse
import dnspython
if __name__ == "__main__":
client = MongoClient("mongodb+srv://rajnesh:<myPassword>@cluster0-chffs.mongodb.net/test?authSource=admin&replicaSet=Cluster0-shard-0&readPreference=primary&appname=MongoDB%20Compass&ssl=true")
print("Hello there!")
However, I get the following Error:
Traceback (most recent call last): File "/Users/rajnesh/pyProgram.py", line 17, in import dnspython ModuleNotFoundError: No module named 'dnspython'
Process finished with exit code 1
Thanks in advance for your help.
For the dnspython package, the import name is "dns". More info about this can be found below: