python-poetry / python-poetry/poetry

Poetry ignores the Python version specified in the pyproject.toml file

Open
#9,779 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/docs
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Description

Poetry uses the version of Python which was used to install Poetry no matter what the pyproject.toml file is configured to use.

Workarounds

poetry env use <VERSION> can be used to create the appropriate version environment first. Since Python 3.13 was just released, this breaks many previously-working configurations.

$ cd (mktemp -d)
$ /var/folders/hs/qvpck5vn/T/tmp.LsjrcWOb39> poetry init --python=3.12 -n
$ /var/folders/hs/qvpck5vn/T/tmp.LsjrcWOb39> python3.12 --version
Python 3.12.7
$ /var/folders/hs/qvpck5vn/T/tmp.LsjrcWOb39> poetry install
The currently activated Python version 3.13.0 is not supported by the project (3.12).
Trying to find and use a compatible version. 

Poetry was unable to find a compatible version. If you have one, you can explicitly use it via the "env use" command.
Poetry Installation Method

system package manager (eg: dnf, apt etc.)

Operating System

macOS

Poetry Version

Poetry (version 1.8.4)

Poetry Configuration
N/A
Python Sysconfig
N/A
Example pyproject.toml
[tool.poetry]
name = "tmp-lsjrcwob39"
version = "0.1.0"
description = ""
authors = ["Chris Adams <chris@improbable.org>"]
readme = "README.md"
packages = [{include = "tmp"}]

[tool.poetry.dependencies]
python = "3.12"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Poetry Runtime Logs
N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown pyproject.toml, Python 3.12, Python 3.13, and the poetry install command; compare that behavior with poetry env use. Trace the environment-selection entry point used by poetry install. Done means Poetry selects an available interpreter satisfying the project's Python constraint instead of relying on the interpreter used to install Poetry.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.