Repository navigation
Inconsistent poetry detection #25524
Description
Discussed in #25522
Originally posted by pdc1 October 12, 2025
Hello,
I have three poetry projects, and two of them get detected and one does not. For the one that does not, the poetry environment gets detected as a venv environment instead. That generally seems to work, but I am nervous that it is not correctly identifying poetry, plus then poetry is not set as the package manager.
If I force it by adding this to my project config, then I get an error about an invalid python interpreter being selected.
"python-envs.defaultEnvManager": "ms-python.python:poetry",
"python-envs.defaultPackageManager": "ms-python.python:poetry",All three poetry environments are in the default "global" location, ~/.cache/pypoetry/virtualenvs/
Are there some steps I can take to see what is going on?
I looked in the output of Python Environments for the project. In particular this part looked promising, but it ends up identified as venv and not poetry:
2025-10-12 16:26:36.667 [info] Discovered manager: (Poetry) /home/paul/.local/bin/poetry
2025-10-12 16:26:36.682 [info] Resolved Python Environment /home/paul/.cache/pypoetry/virtualenvs/convert-audiobooks-jBMuS5Bi-py3.13/bin/python
Here is the full output from a refresh:
2025-10-12 16:26:36.459 [info] Refreshing Poetry Environments
2025-10-12 16:26:36.460 [info] Refreshing poetry environments
2025-10-12 16:26:36.460 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
2025-10-12 16:26:36.478 [info] Discovered manager: (Poetry) /home/paul/.local/bin/poetry
2025-10-12 16:26:36.520 [info] Discovered env: /bin/python3
2025-10-12 16:26:36.523 [info] Discovered env: /usr/bin/python3
2025-10-12 16:26:36.541 [info] [pet] Locator Conda took 60.806657ms
2025-10-12 16:26:36.541 [info] [pet] Locator Homebrew took 84.157µs
2025-10-12 16:26:36.542 [info] [pet] Locator LinuxGlobal took 59.809272ms
2025-10-12 16:26:36.542 [info] [pet] Locator PipEnv took 40.234µs
2025-10-12 16:26:36.542 [info] [pet] Locator Pixi took 25.926µs
2025-10-12 16:26:36.542 [info] [pet] Locator Poetry took 2.194688ms
2025-10-12 16:26:36.542 [info] [pet] Locator PyEnv took 137.422µs
2025-10-12 16:26:36.542 [info] [pet] Locator Venv took 38.97µs
2025-10-12 16:26:36.542 [info] [pet] Locator VirtualEnv took 220.326µs
2025-10-12 16:26:36.543 [info] [pet] Locator VirtualEnvWrapper took 35.704µs
2025-10-12 16:26:36.543 [info] [pet] Locator GlobalVirtualEnvs took 166.525µs
2025-10-12 16:26:36.543 [info] [pet] Locator Locators took 61.34832ms
2025-10-12 16:26:36.543 [info] [pet] Locator Path took 78.985791ms
2025-10-12 16:26:36.543 [info] [pet] Locator Workspaces took 5.979337ms
2025-10-12 16:26:36.544 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
2025-10-12 16:26:36.548 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
2025-10-12 16:26:36.561 [info] [pet] Telemetry: {"event":"RefreshPerformance","data":{"refreshPerformance":{"total":79,"breakdown":{"GlobalVirtualEnvs":0,"Locators":61,"Path":78,"Workspaces":5},"locators":{"Conda":60,"Homebrew":0,"LinuxGlobal":59,"PipEnv":0,"Pixi":0,"Poetry":2,"PyEnv":0,"Venv":0,"VirtualEnv":0,"VirtualEnvWrapper":0}}}}
2025-10-12 16:26:36.622 [info] Discovered manager: (Poetry) /home/paul/.local/bin/poetry
2025-10-12 16:26:36.623 [info] Discovered env: /bin/python3
2025-10-12 16:26:36.631 [info] Discovered env: /usr/bin/python3
2025-10-12 16:26:36.643 [info] Resolved Python Environment /bin/python3
2025-10-12 16:26:36.643 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
2025-10-12 16:26:36.653 [info] [pet] Locator Conda took 85.771511ms
2025-10-12 16:26:36.653 [info] [pet] Locator Homebrew took 454.429µs
2025-10-12 16:26:36.653 [info] [pet] Locator LinuxGlobal took 75.120244ms
2025-10-12 16:26:36.653 [info] [pet] Locator PipEnv took 20.381µs
2025-10-12 16:26:36.653 [info] [pet] Locator Pixi took 59.059µs
2025-10-12 16:26:36.653 [info] [pet] Locator Poetry took 5.472775ms
2025-10-12 16:26:36.654 [info] [pet] Locator PyEnv took 226.417µs
2025-10-12 16:26:36.654 [info] [pet] Locator Venv took 35.027µs
2025-10-12 16:26:36.654 [info] [pet] Locator VirtualEnv took 518.368µs
2025-10-12 16:26:36.654 [info] [pet] Locator VirtualEnvWrapper took 45.909µs
2025-10-12 16:26:36.654 [info] [pet] Locator GlobalVirtualEnvs took 59.984µs
2025-10-12 16:26:36.654 [info] [pet] Locator Locators took 86.074928ms
2025-10-12 16:26:36.654 [info] [pet] Locator Path took 98.002233ms
2025-10-12 16:26:36.654 [info] [pet] Locator Workspaces took 5.813064ms
2025-10-12 16:26:36.655 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
2025-10-12 16:26:36.656 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
2025-10-12 16:26:36.657 [info] [pet] Telemetry: {"event":"RefreshPerformance","data":{"refreshPerformance":{"total":98,"breakdown":{"GlobalVirtualEnvs":0,"Locators":86,"Path":98,"Workspaces":5},"locators":{"Conda":85,"Homebrew":0,"LinuxGlobal":75,"PipEnv":0,"Pixi":0,"Poetry":5,"PyEnv":0,"Venv":0,"VirtualEnv":0,"VirtualEnvWrapper":0}}}}
2025-10-12 16:26:36.663 [info] Resolved Python Environment /bin/python3
2025-10-12 16:26:36.664 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
2025-10-12 16:26:36.667 [info] Discovered manager: (Poetry) /home/paul/.local/bin/poetry
2025-10-12 16:26:36.682 [info] Resolved Python Environment /home/paul/.cache/pypoetry/virtualenvs/convert-audiobooks-jBMuS5Bi-py3.13/bin/python
2025-10-12 16:26:36.767 [info] Discovered env: /usr/bin/python3
2025-10-12 16:26:36.768 [info] Discovered env: /bin/python3
2025-10-12 16:26:36.771 [info] Resolved Python Environment /bin/python3
2025-10-12 16:26:36.785 [info] [pet] Locator Conda took 109.04552ms
2025-10-12 16:26:36.785 [info] [pet] Locator Homebrew took 316.101µs
2025-10-12 16:26:36.785 [info] [pet] Locator LinuxGlobal took 109.424151ms
2025-10-12 16:26:36.785 [info] [pet] Locator PipEnv took 68.454µs
2025-10-12 16:26:36.785 [info] [pet] Locator Pixi took 122.523µs
2025-10-12 16:26:36.785 [info] [pet] Locator Poetry took 7.785668ms
2025-10-12 16:26:36.785 [info] [pet] Locator PyEnv took 592.519µs
2025-10-12 16:26:36.785 [info] [pet] Locator Venv took 38.123µs
2025-10-12 16:26:36.785 [info] [pet] Locator VirtualEnv took 38.562µs
2025-10-12 16:26:36.785 [info] [pet] Locator VirtualEnvWrapper took 38.101µs
2025-10-12 16:26:36.785 [info] [pet] Locator GlobalVirtualEnvs took 675.689µs
2025-10-12 16:26:36.785 [info] [pet] Locator Locators took 110.745725ms
2025-10-12 16:26:36.786 [info] [pet] Locator Path took 125.493353ms
2025-10-12 16:26:36.786 [info] [pet] Locator Workspaces took 20.164531ms
2025-10-12 16:26:36.786 [info] [pet] Telemetry: {"event":"RefreshPerformance","data":{"refreshPerformance":{"total":125,"breakdown":{"GlobalVirtualEnvs":0,"Locators":110,"Path":125,"Workspaces":20},"locators":{"Conda":109,"Homebrew":0,"LinuxGlobal":109,"PipEnv":0,"Pixi":0,"Poetry":7,"PyEnv":0,"Venv":0,"VirtualEnv":0,"VirtualEnvWrapper":0}}}}
```</div>
Activity
DonJayamanne commentedon Oct 13, 2025
Paul Close (@pdc1) Please can you
Run Python Environment Tool (PET) in terminal...--verboseoptionpdc1 commentedon Oct 13, 2025
Here is the output requested for the project that doesn't work. I can post the output for one of the projects that does work if that would help:
pdc1 commentedon Oct 14, 2025
FYI, I compared the output with one of the projects that works, and the output is generally the same--I don't see any differences that would explain why one project env is identified as "poetry" and one is identified as a more general "venv".
It does appear the poetry environment was found, given this line in the trace:
pet_poetry::environment_locations] Found pyproject.toml (convert_audiobooks-jBMuS5Bi-py): "convert_audiobooks" in "/home/paul/Projects/AudiobookTools". The full directory name isconvert-audiobooks-jBMuS5Bi-py3.13/but that's also true for the other projects where poetry was detected.Oh wait, I just noticed a subtle difference: the project name has an underscore (convert_audiobooks) and the environment has a hyphen (convert-audiobooks). The other projects where this works have a hyphen in the
pyproject.tomlproject name.A minor observation: if you create a poetry environment using
poetry new temp_temp, it creates the directory as given, with an underscore, the resultingpyproject.tomlhasname = "temp-temp", with a hyphen.And sure enough, when I change my
pyproject.tomlproject name to use a hyphen instead of underscore, the environment is detected as a poetry environment!However, per the Python packaging user guide, underscores are valid in project names:
Given that underscores are valid, but poetry converts underscores to hyphens in the resulting environment directory, I suggest it would be nice if the environment detection could incorporate the fact that poetry does this.
Thanks!
pdc1 commentedon Oct 23, 2025
I didn't open this issue so I can't rename it, but would now suggest something like "Poetry detection doesn't work for project names with underscores".
Thanks!
pdc1 commentedon Oct 30, 2025
Eleanor Boyd (@eleanorjboyd) Don Jayamanne (@DonJayamanne) see above for my investigation and suggestion for renaming the issue.
eleanorjboyd commentedon Oct 30, 2025
great discovery! If poetry is the one that doesn't support underscores wondering if it is a problem on their end? Might be something we could ask for upstream then
pdc1 commentedon Oct 30, 2025
It's not so much that poetry doesn't support underscores in the project name, but rather that it changes them to hyphens when creating the virtual environment name. It's hard to know if that is intentional or an oversight on their part. It would likely be worth asking for something more clearly defined.
github-actions commentedon Nov 30, 2025
Hey Don Jayamanne (@DonJayamanne), this issue might need further attention.
Don Jayamanne (@DonJayamanne), you can help us out by closing this issue if the problem no longer exists, or adding more information.
DonJayamanne commentedon Dec 1, 2025
This should be fixed in the latest version.
microsoft/python-environment-tools#242
Closing for now, if the problem persists in the lates version please ping here and I'll reopen or feel free to create a new issue