From 6d2bad22e9dba3d1bef291b73ce8d201991462ad Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Tue, 21 Oct 2025 22:56:25 -0400 Subject: [PATCH] [Fix] DeprecationWarning: pkg_resources is deprecated as an API. --- python_anticaptcha/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python_anticaptcha/__init__.py b/python_anticaptcha/__init__.py index 2dc4d93..f73e46d 100644 --- a/python_anticaptcha/__init__.py +++ b/python_anticaptcha/__init__.py @@ -1,5 +1,9 @@ from .base import AnticaptchaClient -from pkg_resources import get_distribution, DistributionNotFound +try: + from importlib.metadata import version, PackageNotFoundError +except ImportError: + # Python < 3.8 fallback + from importlib_metadata import version, PackageNotFoundError from .tasks import ( NoCaptchaTaskProxylessTask, RecaptchaV2TaskProxyless, @@ -23,7 +27,7 @@ AnticatpchaException = AnticaptchaException try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: + __version__ = version(__name__) +except PackageNotFoundError: # package is not installed pass