/usr/bin/python3.12 -m poetry -vvv init
This command will guide you through creating your pyproject.toml config.
Package name [foo]:
Version [0.1.0]:
Description []:
Author [None, n to skip]: n
License []:
Loading configuration file /root/.config/pypoetry/config.toml
[findpython:findpython] Running script: ['/usr/bin/python', '-Ic', 'import sys; print(sys.executable)']
Stack trace:
14 /usr/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
13 /usr/lib/python3.12/site-packages/poetry/console/application.py:260 in _run
258│
259│ try:
→ 260│ exit_code = super()._run(io)
261│ except PoetryRuntimeError as e:
262│ io.write_error_line("")
12 /usr/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│
11 /usr/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
10 /usr/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
9 /usr/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:
8 /usr/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
7 /usr/lib/python3.12/site-packages/poetry/console/commands/init.py:84 in handle
82│ return 1
83│
→ 84│ return self._init_pyproject(project_path=project_path)
85│
86│ def _init_pyproject(
6 /usr/lib/python3.12/site-packages/poetry/console/commands/init.py:176 in _init_pyproject
174│ python = (
175│ ">="
→ 176│ + Python.get_preferred_python(config, self.io).minor_version.to_string()
177│ )
178│
5 /usr/lib/python3.12/site-packages/poetry/utils/env/python/manager.py:290 in get_preferred_python
288│ ):
289│ io.write_error_line(
→ 290│ f"Found: {active_python.executable}", verbosity=Verbosity.VERBOSE
291│ )
292│ return active_python
4 /usr/lib/python3.12/site-packages/poetry/utils/env/python/manager.py:180 in executable
178│ @property
179│ def executable(self) -> Path:
→ 180│ return cast("Path", self._python.interpreter)
181│
182│ @property
3 /usr/lib/python3.12/site-packages/findpython/python.py:81 in interpreter
79│ def interpreter(self) -> Path:
80│ if self._interpreter is None:
→ 81│ self._interpreter = Path(self._get_interpreter())
82│ return self._interpreter
83│
2 /usr/lib/python3.12/site-packages/findpython/python.py:237 in _get_interpreter
235│ def _get_interpreter(self) -> str:
236│ script = "import sys; print(sys.executable)"
→ 237│ return _run_script(str(self.executable), script).strip()
238│
239│ def _get_freethreaded(self) -> bool:
1 /usr/lib/python3.12/site-packages/findpython/python.py:23 in _run_script
21│ command = [executable, "-Ic", script]
22│ logger.debug("Running script: %s", command)
→ 23│ return subprocess.run(
24│ command,
25│ stdout=subprocess.PIPE,
CalledProcessError
Command '['/usr/bin/python', '-Ic', 'import sys; print(sys.executable)']' returned non-zero exit status 2.
at /usr/lib64/python3.12/subprocess.py:571 in run
567│ # We don't call process.wait() as .__exit__ does that for us.
568│ raise
569│ retcode = process.poll()
570│ if check and retcode:
→ 571│ raise CalledProcessError(retcode, process.args,
572│ output=stdout, stderr=stderr)
573│ return CompletedProcess(process.args, retcode, stdout, stderr)
574│
575│
Description
With Poetry 2.4 (but not 2.3), various commands fail when Python 2.7 is within the path with the following error:
For example:
or
or
Workarounds
Couldn't find one so far. Removing python 2.7 from the
$PATHis unfortunately not an option as diverse system utilities depend on it (unfortunately, we are currently stuck with a somewhat outdated OS).Poetry Installation Method
pip
Operating System
CentOS 7
Poetry Version
Poetry (version 2.4.1)
Poetry Configuration
Python Sysconfig
I think this is irrelevant for the issue, but I can provide it on request.
Example pyproject.toml
irrelevantPoetry Runtime Logs
poetry-runtime.log