Skip to content

Error when installing in the Poetry virtual environment #422

@lexkosha

Description

@lexkosha

Hey guys. I ran into a problem installing qrcode using poetry 2.1

macOS 15.7.2 (24G325)
virtual Poetry
python 3.13.11

❯ poetry add "qrcode[pil]"
Using version ^8.2 for qrcode

Updating dependencies
Resolving dependencies... (0.0s)

The current project's supported Python range (>=3.12) is not compatible with some of the required packages Python requirement:
  - qrcode requires Python <4.0,>=3.9, so it will not be installable for Python >=4.0

Because no versions of qrcode match >8.2,<9.0
 and qrcode[pil] (8.2) requires Python <4.0,>=3.9, qrcode is forbidden.
So, because project_name depends on qrcode[pil] (^8.2), version solving failed.

  * Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For qrcode, a possible solution would be to set the `python` property to ">=3.12,<4.0"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

How I solved it.

In the project file pyproject.toml change requires-python = '>=3.12' you can have another version 3.*
Dobami the maximum allowed version, for me it looks like requires-python = '>=3.12,<=3.14'. Next, install
poetry add 'qrcode[pil]'

My full pyproject.toml

[project]
name = "name project"
version = "0.1.0"
description = ""
authors = [
    {name = "My name",email = "my email"}
]
readme = "README.md"
requires-python = ">=3.12,<=3.14"
dependencies = [
    "qrcode[pil] (>=8.2,<9.0)"
]


[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions