Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-1368

Motor 3.5 should cap PyMongo dependency to <=4.8

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.5.2
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers

      Motor 3.5 should cap PyMongo dependency to <=4.8 because it is not compatible with 4.9 which was released today. As reported in PYTHON-4771, motor 3.5.1 fails when installed with pymongo 4.9:

      $ pip install motor==3.5.1
      Collecting motor==3.5.1
        Using cached motor-3.5.1-py3-none-any.whl.metadata (21 kB)
      Collecting pymongo<5,>=4.5 (from motor==3.5.1)
        Using cached pymongo-4.9-cp312-cp312-macosx_11_0_arm64.whl.metadata (22 kB)
      Collecting dnspython<3.0.0,>=1.16.0 (from pymongo<5,>=4.5->motor==3.5.1)
        Using cached dnspython-2.6.1-py3-none-any.whl.metadata (5.8 kB)
      Using cached motor-3.5.1-py3-none-any.whl (74 kB)
      Using cached pymongo-4.9-cp312-cp312-macosx_11_0_arm64.whl (939 kB)
      Using cached dnspython-2.6.1-py3-none-any.whl (307 kB)
      Installing collected packages: dnspython, pymongo, motor
      Successfully installed dnspython-2.6.1 motor-3.5.1 pymongo-4.9
      $ python
      >>> from motor.motor_asyncio import AsyncIOMotorClient
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/Users/shane/.venv-312/lib/python3.12/site-packages/motor/motor_asyncio.py", line 16, in <module>
          from . import core, motor_gridfs
        File "/Users/shane/.venv-312/lib/python3.12/site-packages/motor/core.py", line 30, in <module>
          from pymongo.cursor import _QUERY_OPTIONS, Cursor, RawBatchCursor
      ImportError: cannot import name '_QUERY_OPTIONS' from 'pymongo.cursor' (/Users/shane/.venv-312/lib/python3.12/site-packages/pymongo/cursor.py)
      

      For anyone encountering this issue, the current fix is to either:

      1. Upgrade to motor 3.6.0 which is compatible with (and requires) PyMongo >=4.9: pip install --upgrade 'motor>=3.6'
      2. If you're using motor <3.6 and can't upgrade, cap the pymongo version to <4.9: eg pip install --upgrade 'motor==3.5.1' 'pymongo<4.9'

      Apologies for the inconvenience.

            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: