diff --git a/pymilvus/client/__init__.py b/pymilvus/client/__init__.py index 800d36b25..c84910369 100644 --- a/pymilvus/client/__init__.py +++ b/pymilvus/client/__init__.py @@ -3,16 +3,18 @@ import subprocess from contextlib import suppress -from pkg_resources import DistributionNotFound, get_distribution +try: + from importlib.metadata import version, PackageNotFoundError +except ImportError: + # For Python versions < 3.8 + from importlib_metadata import version, PackageNotFoundError log = logging.getLogger(__name__) - __version__ = "0.0.0.dev" - -with suppress(DistributionNotFound): - __version__ = get_distribution("pymilvus").version +with suppress(PackageNotFoundError): + __version__ = version("pymilvus") def get_commit(version: str = "", short: bool = True) -> str: