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

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

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.12, 4.0
    • Component/s: None
    • Labels:
      None

      Description

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: