Skip to content

Python 3.12-dev & Windows: zipimporter has no attribute find_module #11688

@kdeldycke

Description

@kdeldycke

Description

The vendored version of pkg_resources in pip fails with Python 3.12-dev on Windows.

Expected behavior

No response

pip version

22.3.1

Python version

3.12.0-alpha.3 (x64)

OS

Windows 2022 & 2019

How to Reproduce

Tl;Dr, you just have to run in Windows with Python 3.12:

$ pip download --no-binary=:all: --no-deps --dest ./local-download/ pygments==2.14.0 

The long version is that I am emulating the CLI above in my code, by mimicking some of pip's internals.

That way I can download the source distribution of the Pygments version I depends on, and inspect its test data files which are not distributed as part of the wheel.

This construction is working perfectly on the full matrix of:

  • Distributions:
    • ubuntu-22.04
    • ubuntu-20.04
    • macos-12
    • macos-11
    • windows-2022
    • windows-2019
  • Python versions:
    • 3.7
    • 3.8
    • 3.9
    • 3.10
    • 3.11
    • 3.12-dev

But not on the combination of 3.12-dev with either windows-2022 or windows-2019.

See the result of this matrix execution here, and the exact trace here.

Output

C:\(...)\pip\_internal\cli\req_command.py:247: in wrapper return func(self, options, args) C:\(...)\pip\_internal\commands\download.py:93: in run session = self.get_default_session(options) C:\(...)\pip\_internal\cli\req_command.py:98: in get_default_session self._session = self.enter_context(self._build_session(options)) C:\(...)\pip\_internal\cli\req_command.py:125: in _build_session session = PipSession( C:\(...)\pip\_internal\network\session.py:343: in __init__ self.headers["User-Agent"] = user_agent() C:\(...)\pip\_internal\network\session.py:175: in user_agent setuptools_dist = get_default_environment().get_distribution("setuptools") C:\(...)\pip\_internal\metadata\importlib\_envs.py:188: in get_distribution return next(matches, None) C:\(...)\pip\_internal\metadata\importlib\_envs.py:183: in <genexpr> matches = ( C:\(...)\pip\_internal\metadata\base.py:612: in iter_all_distributions for dist in self._iter_distributions(): C:\(...)\pip\_internal\metadata\importlib\_envs.py:176: in _iter_distributions for dist in finder.find_eggs(location): C:\(...)\pip\_internal\metadata\importlib\_envs.py:144: in find_eggs yield from self._find_eggs_in_dir(location) C:\(...)\pip\_internal\metadata\importlib\_envs.py:111: in _find_eggs_in_dir from pip._vendor.pkg_resources import find_distributions C:\(...)\pip\_vendor\pkg_resources\__init__.py:3251: in <module> @_call_aside C:\(...)\pip\_vendor\pkg_resources\__init__.py:3235: in _call_aside f(*args, **kwargs) C:\(...)\pip\_vendor\pkg_resources\__init__.py:3277: in _initialize_master_working_set tuple( C:\(...)\pip\_vendor\pkg_resources\__init__.py:3278: in <genexpr> dist.activate(replace=False) C:\(...)\pip\_vendor\pkg_resources\__init__.py:2785: in activate declare_namespace(pkg) C:\(...)\pip\_vendor\pkg_resources\__init__.py:2284: in declare_namespace _handle_ns(packageName, path_item) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def _handle_ns(packageName, path_item): """Ensure that named package includes a subpath of path_item (if needed)""" importer = get_importer(path_item) if importer is None: return None # capture warnings due to #1111 with warnings.catch_warnings(): warnings.simplefilter("ignore") > loader = importer.find_module(packageName) E AttributeError: 'zipimporter' object has no attribute 'find_module'. Did you mean: 'load_module'? C:\(...)\pip\_vendor\pkg_resources\__init__.py:2201: AttributeError

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions