← All tasks
pythonpython-poetry/poetry #10490Not a task: already works

bug: poetry is using default python version instead of venv python as result of new version in virtualenv v20.33.0

envgap__python-poetry__poetry-10490

01 / FAILURE SIGNATURE

As reported upstream

error:
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
2d12833298a7f7cc6f93942304aa7ad9398a5da1
Manifest
pyproject.toml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

python-poetry/poetry #10490 · read the original issue
### Description

poetry is using the wrong python version when running in github action. it uses the machine default version instead of the venv python version.
```
Using virtualenv: /home/runner/.cache/pypoetry/virtualenvs/lb-kafka-C-kvVqEG-py3.13
....
error:
Current Python version (3.12.3) is not allowed by the project (~=3.13).
Please change python executable via the "env use" command.
Error: Process completed with exit code 1.
```


### Workarounds

locking virtualenv==20.32.0 when installing poetry using constraints.txt as pip args fixes the issue.

### Poetry Installation Method

pipx

### Operating System

Ubuntu

### Poetry Version

2.1.3

### Poetry Configuration

```bash session
cache-dir = "/home/runner/.cache/pypoetry"
data-dir = "/home/runner/.local/share/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}/python"  # /home/runner/.local/share/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/runner/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false
```

### Python Sysconfig

<details>
  <summary>sysconfig.log</summary>
  <!-- Please leave one blank line below for enabling the code block rendering. -->

  ```
  Paste the output of 'python -m sysconfig', over this line.
  ```
</details>


### Example pyproject.toml

```TOML

```

### Poetry Runtime Logs

<details>
  <summary>poetry-runtime.log</summary>
  <!-- Please leave one blank line below for enabling the code block rendering. -->

  ```
  Stack trace:

  8  /opt/pipx/venvs/poetry/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/pipx/venvs/poetry/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("")

  6  /opt/pipx/venvs/poetry/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/pipx/venvs/poetry/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/pipx/venvs/poetry/lib/python3.12/site-packages/cleo/application.py:454 in _run_command
      452│ 
      453│         try:
    → 454│             self._event_dispatcher.dispatch(command_event, COMMAND)
      455│ 
      456│             if command_event.command_should_run():

  3  /opt/pipx/venvs/poetry/lib/python3.12/site-packages/cleo/events/event_dispatcher.py:26 in dispatch
       24│ 
       25│         if listeners:
    →  26│             self._do_dispatch(listeners, event_name, event)
       27│ 
       28│         return event

  2  /opt/pipx/venvs/poetry/lib/python3.12/site-packages/cleo/events/event_dispatcher.py:85 in _do_dispatch
       83│                 break
       84│ 
    →  85│             listener(event, event_name, self)
       86│ 
       87│     def _sort_listeners(self, event_name: str) -> None:

  1  /opt/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/console/application.py:581 in configure_env
      579│ 
      580│         env_manager = EnvManager(poetry, io=io)
    → 581│         env = env_manager.create_venv()
      582│ 
      583│         if env.is_venv() and io.is_verbose():

  InvalidCurrentPythonVersionError

  Current Python version (3.12.3) is not allowed by the project (~=3.13).
  Please change python executable via the "env use" command.

  at /opt/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/utils/env/env_manager.py:392 in create_venv
      388│             current_python = Version.parse(
      389│                 ".".join(str(c) for c in env.version_info[:3])
      390│             )
      391│             if not self._poetry.package.python_constraint.allows(current_python):
    → 392│                 raise InvalidCurrentPythonVersionError(
      393│                     self._poetry.package.python_versions, str(current_python)
      394│                 )
      395│             return env
      396│ 
Loading configuration file /home/runner/.config/pypoetry/config.toml
  ```
</details>
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]