Skip to content

Replace deprecated pkg_resources with importlib.metadata in profile_report.p #1816

@yurivski

Description

@yurivski

Current Behaviour

profile_report.py imports pkg_resources directly (line 11), which was removed
from setuptools>=81. This causes ModuleNotFoundError: No module named 'pkg_resources'
on fresh environments with modern setuptools.

The utils/versions.py file already uses importlib.metadata with a fallback —
but profile_report.py was not updated.

Affected code

  • src/ydata_profiling/profile_report.py (lines 11 and 362)

Proposed fix

Replace pkg_resources.get_distribution("Pillow").version with
importlib.metadata.version("Pillow"), which is available since Python 3.8.

Validation

Full test suite passes with the change on Python 3.13.5 (2195 passed, 4 skipped, 0 failures).

I'd like to work on this. Will open a PR once approved.

Expected Behaviour

ydata-profiling should work without requiring setuptools/pkg_resources at runtime.

Data Description

N/A - not data related

Code that reproduces the bug

pip install setuptools>=81
python3 -c "from ydata_profiling import ProfileReport"
# ModuleNotFoundError: No module named 'pkg_resources'

pandas-profiling version

4.18.1 (develop branch)

Dependencies

setuptools==78.1.1 (tested); bug triggers on setuptools>=81 where pkg_resources was removed
Python 3.13.5

OS

Linux (Parrot OS)

Checklist

  • There is not yet another bug report for this issue in the issue tracker
  • The problem is reproducible from this bug report. This guide can help to craft a minimal bug report.
  • The issue has not been resolved by the entries listed under Common Issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions