Skip to content

Deprecation warning: pkg_resources is deprecated, replace with importlib.metadata #2388

@m-awais-khan

Description

@m-awais-khan

Description

Running manimgl on Python 3.13+ shows a warning:

UserWarning: pkg_resources is deprecated as an API...

This is because __init__.py imports pkg_resources only to fetch the version string.

Fix

Replaced:

import pkg_resources
__version__ = pkg_resources.get_distribution("manimgl").version

with:

try:
    from importlib.metadata import version, PackageNotFoundError
except ImportError:  # For Python <3.8 fallback
    from importlib_metadata import version, PackageNotFoundError  # type: ignore

try:
    __version__ = version("manimgl")
except PackageNotFoundError:
    __version__ = "unknown"

This removes the warning and uses the modern, built-in API.

Pull Request

I’ve submitted a PR with this change here: #2389

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions