ydataai / ydata-profiling

1 Line of code data quality profiling & exploratory data analysis for Pandas and Spark DataFrames.
https://docs.profiling.ydata.ai
MIT License
12.51k stars 1.68k forks source link

ModuleNotFoundError: No module named 'pkg_resources' #1618

Open abdrysdale opened 3 months ago

abdrysdale commented 3 months ago

Current Behaviour

Thanks for the great repository!

Currently fails on the import with

import ydata_profilling

Resulting in:

Traceback (most recent call last):
  File "c:\Users\foo\test.py", line 9, in <module>
    import ydata_profiling
  File "C:\Users\foo\AppData\Local\pypoetry\Cache\virtualenvs\foo-nnQxNQNi-py3.12\Lib\site-packages\ydata_profiling\__init__.py", line 14, in <module>
    from ydata_profiling.compare_reports import compare  # isort:skip # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\foo\AppData\Local\pypoetry\Cache\virtualenvs\foo-nnQxNQNi-py3.12\Lib\site-packages\ydata_profiling\compare_reports.py", line 12, in <module>
    from ydata_profiling.profile_report import ProfileReport
  File "C:\Users\foo\AppData\Local\pypoetry\Cache\virtualenvs\foo-nnQxNQNi-py3.12\Lib\site-packages\ydata_profiling\profile_report.py", line 9, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Expected Behaviour

The library should be successfully imported.

Data Description

Currently not using any data as it fails on the import.

Code that reproduces the bug

import ydata_profiling

pandas-profiling version

4.8.3

Dependencies

annotated-types==0.7.0
attrs==23.2.0
certifi==2024.7.4
charset-normalizer==3.3.2
colorama==0.4.6
contourpy==1.2.1
cycler==0.12.1
dacite==1.8.1
fonttools==4.53.1
h5py==3.11.0
htmlmin==0.1.12
idna==3.7
ImageHash==4.3.1
Jinja2==3.1.4
joblib==1.4.2
kiwisolver==1.4.5
llvmlite==0.43.0
MarkupSafe==2.1.5
matplotlib==3.8.4
multimethod==1.12
networkx==3.3
numba==0.60.0
numpy==1.26.4
packaging==24.1
pandas==2.2.2
patsy==0.5.6
phik==0.12.4
pillow==10.4.0
pydantic==2.8.2
pydantic_core==2.20.1
pydicom==2.4.4
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
PyWavelets==1.6.0
PyYAML==6.0.1
requests==2.32.3
scipy==1.13.1
seaborn==0.13.2
six==1.16.0
statsmodels==0.14.2
tqdm==4.66.4
typeguard==4.3.0
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2
visions==0.7.6
wordcloud==1.9.3
ydata-profiling==4.8.3

OS

Windows 11

Checklist

abdrysdale commented 3 months ago

This seems to be due to setuptools not being installed. A simple pip install setuptools or poetry add setuptools solves the issue.

abdrysdale commented 3 months ago

I've created a pull request for the fix which includes setuptools in the requirements.

However, it is worth noting that pkg_resources is being slowly depreciated in favor of importlib.resources and there is also a really handy migration guide on the subject matter.

It's worth noting that importlib.resources only supports the following APIs:

so importlib.resources may not be an appropriate.