Skip to content

Commit 491589a

Browse files
[Fix] DeprecationWarning: pkg_resources is deprecated as an API. (#108)
1 parent 076922e commit 491589a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

python_anticaptcha/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from .base import AnticaptchaClient
2-
from pkg_resources import get_distribution, DistributionNotFound
2+
try:
3+
from importlib.metadata import version, PackageNotFoundError
4+
except ImportError:
5+
# Python < 3.8 fallback
6+
from importlib_metadata import version, PackageNotFoundError
37
from .tasks import (
48
NoCaptchaTaskProxylessTask,
59
RecaptchaV2TaskProxyless,
@@ -23,7 +27,7 @@
2327
AnticatpchaException = AnticaptchaException
2428

2529
try:
26-
__version__ = get_distribution(__name__).version
27-
except DistributionNotFound:
30+
__version__ = version(__name__)
31+
except PackageNotFoundError:
2832
# package is not installed
2933
pass

0 commit comments

Comments
 (0)