simion/pip-upgrader

Python 3.12 removed pkgutil.ImpImporter

lsteeger opened this issue · 2 comments

After upgrade to Python 3.12, pip-upgrade fails as follows:

pip-upgrade
Traceback (most recent call last):
  File "./.venv/bin/pip-upgrade", line 5, in <module>
    from pip_upgrader.cli import main
  File "./.venv/lib/python3.12/site-packages/pip_upgrader/__init__.py", line 1, in <module>
    import pkg_resources
  File "./.venv/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2191, in <module>
    register_finder(pkgutil.ImpImporter, find_on_path)
                    ^^^^^^^^^^^^^^^^^^^

From Python 3.11 doc:

class pkgutil.ImpImporter(dirname=None)

    [PEP 302](https://peps.python.org/pep-0302/) Finder that wraps Python’s “classic” import algorithm.

    If dirname is a string, a [PEP 302](https://peps.python.org/pep-0302/) finder is created that searches
that directory. If dirname is None, a [PEP 302](https://peps.python.org/pep-0302/) finder is created that
searches the current [sys.path] (https://docs.python.org/3.11/library/sys.html#sys.path),
plus any modules that are frozen or built-in.

    Note that [ImpImporter](https://docs.python.org/3.11/library/pkgutil.html#pkgutil.ImpImporter) does
not currently support being used by placement on
[sys.meta_path](https://docs.python.org/3.11/library/sys.html#sys.meta_path).

    Deprecated since version 3.3: This emulation is no longer needed, as the standard import mechanism
is now fully [PEP 302](https://peps.python.org/pep-0302/) compliant and available in
[importlib](https://docs.python.org/3.11/library/importlib.html#module-importlib).

Apparently the deprecation has now become a removal.