Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.12 removed pkgutil.ImpImporter #51

Open
lsteeger opened this issue May 28, 2024 · 1 comment
Open

Python 3.12 removed pkgutil.ImpImporter #51

lsteeger opened this issue May 28, 2024 · 1 comment

Comments

@lsteeger
Copy link

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.

@ross-spencer
Copy link
Contributor

Seeing a similar deprecation <> removal with pkg_resources:

Traceback (most recent call last):
  File "/home/r0ss/git/ross-spencer/template.py/venv/bin/pip-upgrade", line 5, in <module>
    from pip_upgrader.cli import main
  File "/home/r0ss/git/ross-spencer/template.py/venv/lib/python3.12/site-packages/pip_upgrader/__init__.py", line 1, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
make: *** [Makefile:28: upgrade] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants