poetry
poetry copied to clipboard
The `poentry install` command does not modify the file `env.toml`
Description
Steps to reproduce:
- Create a poetry project.
- Install two python versions: for example, python 3.12.2 and 3.12.3.
-
poetry env use /<path to python 3.12.2>/bin/python
. - Delete existing env
rm -rf $(poetry env info --path)
. - Create a new one with
poetry install
(Poetry will use the newest patch version by default 3.12.3). - Run command
poetry env use /.../pypoetry/virtualenvs/poetry-project-name/bin/python
Poetry deletes the existing poetry environment with an error: Could not find the python executable /.../pypoetry/virtualenvs/poetry-project-name/bin/python
Workarounds
Manually change the version of the interpreter in the file env.toml
.
In my example from 3.12.2 to 3.12.3.
Poetry Installation Method
system package manager (eg: dnf, apt etc.)
Operating System
MacOS Sonoma 14.3.1
Poetry Version
1.7.1
Poetry Configuration
cache-dir = "/Users/Egor.Eliseev/Library/Caches/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/Egor.Eliseev/Library/Caches/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true
Python Sysconfig
No response
Example pyproject.toml
[tool.poetry]
name = "poetry-pro"
version = "0.1.0"
description = ""
authors = ["Some Dev <[email protected]>"]
packages = []
[tool.poetry.dependencies]
python = "^3.12"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Poetry Runtime Logs
Stack trace:
8 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/cleo/application.py:327 in run
325│
326│ try:
→ 327│ exit_code = self._run(io)
328│ except BrokenPipeError:
329│ # If we are piped to another process, it may close early and send a
7 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/poetry/console/application.py:190 in _run
188│ self._load_plugins(io)
189│
→ 190│ exit_code: int = super()._run(io)
191│ return exit_code
192│
6 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/cleo/application.py:431 in _run
429│ io.input.interactive(interactive)
430│
→ 431│ exit_code = self._run_command(command, io)
432│ self._running_command = None
433│
5 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/cleo/application.py:473 in _run_command
471│
472│ if error is not None:
→ 473│ raise error
474│
475│ return terminate_event.exit_code
4 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/cleo/application.py:457 in _run_command
455│
456│ if command_event.command_should_run():
→ 457│ exit_code = command.run(io)
458│ else:
459│ exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED
3 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/cleo/commands/base_command.py:117 in run
115│ io.input.validate()
116│
→ 117│ return self.execute(io) or 0
118│
119│ def merge_application_definition(self, merge_args: bool = True) -> None:
2 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/cleo/commands/command.py:61 in execute
59│
60│ try:
→ 61│ return self.handle()
62│ except KeyboardInterrupt:
63│ return 1
1 /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/poetry/console/commands/env/use.py:24 in handle
22│ return 0
23│
→ 24│ env = manager.activate(self.argument("python"))
25│
26│ self.line(f"Using virtualenv: {env.path}")
PythonVersionNotFound
Could not find the python executable /.../pypoetry/virtualenvs/poetry-project-name-py3.12/bin/python
at /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/poetry/utils/env/env_manager.py:141 in activate
137│ pass
138│
139│ python_path = self._full_python_path(python)
140│ if python_path is None:
→ 141│ raise PythonVersionNotFound(python)
142│
143│ try:
144│ python_version_string = subprocess.check_output(
145│ [python_path, "-c", GET_PYTHON_VERSION_ONELINER], text=True