Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pymongo/uri_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""Tools to parse and validate a MongoDB URI."""
import re
import warnings
import sys

from urllib.parse import unquote_plus

Expand Down Expand Up @@ -416,8 +417,12 @@ def parse_uri(uri, default_port=DEFAULT_PORT, validate=True, warn=False,
scheme_free = uri[SCHEME_LEN:]
elif uri.startswith(SRV_SCHEME):
if not _HAVE_DNSPYTHON:
raise ConfigurationError('The "dnspython" module must be '
'installed to use mongodb+srv:// URIs')
python_path = sys.executable or "python"
raise ConfigurationError(
'The "dnspython" module must be '
'installed to use mongodb+srv:// URIs. '
'To fix this error install pymongo with the srv extra:\n '
'%s -m pip install "pymongo[srv]"' % (python_path))
is_srv = True
scheme_free = uri[SRV_SCHEME_LEN:]
else:
Expand Down