pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
7.62k stars 371 forks source link

Error while trying to init a new project #2792

Closed m-aherron closed 3 months ago

m-aherron commented 3 months ago

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

pdm init 

in a directory without a project

Actual behavior

Errors out with this message (truncated)

File "C:\GlobalScoopApps\pipx\venvs\pdm\Lib\site-packages\pdm\project\core.py", line 731, in _get_python_finder
    finder = Finder(resolve_symlinks=True, selected_providers=providers or None)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\GlobalScoopApps\pipx\venvs\pdm\Lib\site-packages\findpython\finder.py", line 32, in __init__
    self._providers = self.setup_providers(selected_providers)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\GlobalScoopApps\pipx\venvs\pdm\Lib\site-packages\findpython\finder.py", line 41, in setup_providers
    allowed_providers = {name: ALL_PROVIDERS[name] for name in selected_providers}
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\GlobalScoopApps\pipx\venvs\pdm\Lib\site-packages\findpython\finder.py", line 41, in <dictcomp>
    allowed_providers = {name: ALL_PROVIDERS[name] for name in selected_providers}
                               ~~~~~~~~~~~~~^^^^^^
KeyError: 'venv'

This is the contents of two variables just before it errors:

allowed_providers

{'path': <class 'findpython.providers.path.PathProvider'>,
 'asdf': <class 'findpython.providers.asdf.AsdfProvider'>,
 'pyenv': <class 'findpython.providers.pyenv.PyenvProvider'>,
 'rye': <class 'findpython.providers.rye.RyeProvider'>,
 'winreg': <class 'findpython.providers.winreg.WinregProvider'>,
 'macos': <class 'findpython.providers.macos.MacOSProvider'>}
selected_providers

['venv', 'path', 'asdf', 'pyenv', 'rye', 'winreg', 'macos']

Expected behavior

pdm init has worked on this system.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
❯ pdm info
[ProjectError]: The pyproject.toml has not been initialized yet. You can do this by running `pdm init`.

On a previous successful init:

❯ pdm info
PDM version:
  2.13.3
Python Interpreter:
  c:\Python\PYD_dev\.venv\Scripts\python.exe (3.11)
Project Root:
  C:/Python/PYD_dev
Local Packages:

and

❯ pdm info --env
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.7",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.19045",
  "python_full_version": "3.11.7",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "win32"
}

I tried reverting as far back as 2.13.0 to no avail.

frostming commented 3 months ago

Did you set the python.providers config?

m-aherron commented 3 months ago

Works as intended - thank you.