diff --git a/pymongo/__init__.py b/pymongo/__init__.py index 7ee177bdae..8116788bc3 100644 --- a/pymongo/__init__.py +++ b/pymongo/__init__.py @@ -88,7 +88,6 @@ from pymongo import _csot from pymongo._version import __version__, get_version_string, version_tuple -from pymongo.asynchronous.mongo_client import AsyncMongoClient from pymongo.common import MAX_SUPPORTED_WIRE_VERSION, MIN_SUPPORTED_WIRE_VERSION from pymongo.cursor import CursorType from pymongo.operations import ( @@ -105,6 +104,14 @@ from pymongo.synchronous.mongo_client import MongoClient from pymongo.write_concern import WriteConcern +try: + from pymongo.asynchronous.mongo_client import AsyncMongoClient +except Exception as e: + # PYTHON-4781: Importing asyncio can fail on Windows. + import warnings as _warnings + + _warnings.warn(f"Failed to import Async PyMongo: {e!r}", ImportWarning, stacklevel=2) + version = __version__ """Current version of PyMongo."""