jpmml / jpmml-evaluator-python

PMML evaluator library for Python
GNU Affero General Public License v3.0
20 stars 9 forks source link

ModuleNotFoundError: No module named 'pkg_resources' with Python 3.12 #27

Open sivanantha321 opened 3 weeks ago

sivanantha321 commented 3 weeks ago

From the pkg_resources docs: https://setuptools.pypa.io/en/latest/pkg_resources.html

Use of pkg_resources is deprecated in favor of [importlib.resources] (https://docs.python.org/3.11/library/importlib.resources.html#module-importlib.resources), [importlib.metadata] (https://docs.python.org/3.11/library/importlib.metadata.html#module-importlib.metadata) and their backports (importlib_resources, [importlib_metadata] (https://pypi.org/project/importlib_metadata)). Some useful APIs are also provided by [packaging] (https://pypi.org/project/packaging) (e.g. requirements and version parsing). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.

Python 3.12 has removed pkg_resources from the standard library (moved to setuptools): https://docs.python.org/3/whatsnew/3.12.html

https://github.com/python/cpython/issues/95299: Do not pre-install setuptools in virtual environments created with [venv] (https://docs.python.org/3/library/venv.html#module-venv). This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the [activated] (https://docs.python.org/3/library/venv.html#venv-explanation) virtual environment.

Traceback:
/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
pmmlserver/pmmlserver/__init__.py:15: in <module>
    from .model import PmmlModel  # noqa # pylint: disable=unused-import
pmmlserver/pmmlserver/model.py:19: in <module>
    from jpmml_evaluator import make_evaluator
pmmlserver/.venv/lib/python3.12/site-packages/jpmml_evaluator/__init__.py:7: in <module>
    import pkg_resources
E   ModuleNotFoundError: No module named 'pkg_resources'
vruusmann commented 3 weeks ago

Noted.

The package is currently tested using Python 3.7 through 3.11: https://github.com/jpmml/jpmml-evaluator-python/blob/0.10.3/.github/workflows/python.yaml

Maybe it's time to drop Python 3.7 and 3.8 from the list, and add Python 3.12 to it.