-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
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:
- Upgrade to motor 3.6.0 which is compatible with (and requires) PyMongo >=4.9: pip install --upgrade 'motor>=3.6'
- 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.
- is duplicated by
-
MOTOR-1371 PyMongo ImportError when using motor
- Closed
- related to
-
PYTHON-4771 Cannot import _QUERY_OPTIONS on Pymongo 4.9
- Closed
-
MOTOR-1351 Bump minimum PyMongo version to 4.9
- Closed