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

uri_parser.py (line 467): NameError: name 'sys' is not defined

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Unknown
    • Resolution: Fixed
    • 4.1
    • 3.13, 4.1.1
    • None
    • None

    Description

      install pymongo in fresh python environment (do not install dnspython)

      try to initialize a MongoClient using a mongodb+srv url

      (pymongo-test) ***@*******:~# python
      Python 3.8.12 (default, Dec 22 2021, 16:14:18)
      [GCC 9.3.0] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import pymongo
      >>> pymongo._version_
      '4.1.0'
      >>> url = "mongodb+srv://*****/test?retryWrites=true"
      >>> client = pymongo.MongoClient(url)
      Traceback (most recent call last):
      {{ File "<stdin>", line 1, in <module>}}
      {{ File "/root/.pyenv/versions/pymongo-test/lib/python3.8/site-packages/pymongo/mongo_client.py", line 704, in _init_}}
      {{ res = uri_parser.parse_uri(}}
      {{ File "/root/.pyenv/versions/pymongo-test/lib/python3.8/site-packages/pymongo/uri_parser.py", line 467, in parse_uri}}
      {{ python_path = sys.executable or "python"}}
      NameError: name 'sys' is not defined

      if dnspython is installed, this code isn't executed, so no problems there.

      Attachments

        Issue Links

          Activity

            People

              shane.harvey@mongodb.com Shane Harvey
              caleb.spraul@nowigence.com caleb spraul
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: