Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2605

Improve mongodb+srv:// error message when dnspython is not installed

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.12, 4.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Note: dnspython is now a dependency of pymongo 4.3+ and will be automatically installed when installing those versions of pymongo.

      When a user attempts to use a mongodb+srv:// connection string when dnspython is not installed we raise this error:

      >>> client = pymongo.MongoClient(
      ...    "mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority")
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/Users/shane/.venv/lib/python3.9/site-packages/pymongo/mongo_client.py", line 639, in __init__
          res = uri_parser.parse_uri(
        File "/Users/shane/.venv/lib/python3.9/site-packages/pymongo/uri_parser.py", line 428, in parse_uri
          raise ConfigurationError('The "dnspython" module must be '
      pymongo.errors.ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs
      

      We should generate the command they need to run so they can copy/paste it, like this:

      pymongo.errors.ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs. To fix this error install pymongo with the srv extra:
          /Users/shane/git/mongo-python-driver/.venv/bin/python -m pip install 'pymongo[srv]'
      

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: