pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.89k stars 1.87k forks source link

KeyError: 'Name' on distributions #6271

Closed TurnrDev closed 1 month ago

TurnrDev commented 1 month ago

Introduced in b1c14a2e18e90b3b77467d0fb19b70ce410be396, I am getting the following error:

Loading .env environment variables...
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Traceback (most recent call last):
  File "/opt/homebrew/bin/pipenv", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/cli/options.py", line 52, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/cli/command.py", line 207, in install
    do_install(
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/routines/install.py", line 93, in do_install
    do_init(
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/routines/install.py", line 649, in do_init
    do_lock(
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/routines/lock.py", line 67, in do_lock
    venv_resolve_deps(
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/utils/resolver.py", line 788, in venv_resolve_deps
    pipenv_site_dir = get_pipenv_sitedir()
                      ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/utils/resolver.py", line 965, in get_pipenv_sitedir
    if dist.metadata["Name"].lower() == "pipenv":
       ~~~~~~~~~~~~~^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pipenv/vendor/importlib_metadata/_adapters.py", line 54, in __getitem__
    raise KeyError(item)
KeyError: 'Name'

Downgrading to any version below 2024.0.0 prevents the error.

TurnrDev commented 1 month ago

Update, it appears my machine had a broken install of the package called packaging

badench commented 1 month ago

I am having a very similar problem

Installing dependencies from Pipfile.lock (926f54)...
: ERROR: Exception:
: Traceback (most recent call last):
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/cli/base_command.py", line 179, in exc_logging_wrapper
:     status = run_func(*args)
:              ^^^^^^^^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/cli/req_command.py", line 67, in wrapper
:     return func(self, options, args)
:            ^^^^^^^^^^^^^^^^^^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/commands/install.py", line 362, in run
:     resolver = self.make_resolver(
:                ^^^^^^^^^^^^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/cli/req_command.py", line 177, in make_resolver
:     return 
pipenv.patched.pip._internal.resolution.resolvelib.resolver.Resolver(
:            
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/resolver.py", line 58, in __init__
:     self.factory = Factory(
:                    ^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/resolution
/resolvelib/factory.py", line 127, in __init__
:     self._installed_dists = {
:                             ^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/resolution/resolvelib/factory.py", line 127, in <dictcomp>
:     self._installed_dists = {
:                             ^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/metadata/base.py", line 664, in <genexpr>
:     return (d for d in it if d.canonical_name not in skip)
:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/metadata/base.py", line 612, in iter_all_distributions
:     for dist in self._iter_distributions():
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/metadata/importlib/_envs.py", line 176, in _iter_distributions
:     yield from finder.find(location)
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/metadata/importlib/_envs.py", line 79, in find
:     for dist, info_location in self._find_impl(location):
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/metadata/importlib/_envs.py", line 64, in _find_impl
:     raw_name = get_dist_name(dist)
:                ^^^^^^^^^^^^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/patched/pip/_internal/metadata/importlib/_compat.py", line 52, in get_dist_name
:     name = cast(Any, dist).name
:            ^^^^^^^^^^^^^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/vendor/importlib_metadata/__init__.py", line 4[98](https://gitlab.com/aeqium/aeqium/-/jobs/8026873278#L98), in name
:     return self.metadata['Name']
:            ~~~~~~~~~~~~~^^^^^^^^
:   File "/usr/local/lib/python3.11/site-packages/pipenv/vendor/importlib_metadata/_adapters.py", line 54, in __getitem__
:     raise KeyError(item)
: KeyError: 'Name'
ERROR: Couldn't install package: {}

I've tried searching around but nothing seems to be helping