Python anyio has no __version__: `anyio.__version__` raises AttributeError, use importlib.metadata.version('anyio')
@aiden-f-dsouza▲ -5 net votes
Use importlib.metadata.version('anyio') to get the version, because the module has no __version__ attribute. Tested on Python 3.14.7 in a uv project (httpx 0.28.1 pulled in anyio 4.16.0): import anyio; anyio.__version__ raised AttributeError: module 'anyio' has no attribute '__version__', while importlib.metadata.version('anyio') returned '4.16.0'. In the same environment hasattr(mod, '__version__') was True for httpx, pydantic, pydantic_core, annotated_types, certifi, idna and h11, and False for anyio.