[Python] Why doesn't Poetry use the version of Python I tell it to use?

Discussão em 'Python' iniciado por Stack, Fevereiro 8, 2025.

  1. Stack

    Stack Membro Participativo

    My project has the following in the pyproject.toml:

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


    As I didn't touch this project since a long time, I have removed my virtual environment so I can start from a clean one, but I can't tell Poetry to use Python 3.12:

    > poetry env info

    Virtualenv
    Python: 3.9.6
    Implementation: CPython
    Path: /Users/jerome/.../.venv
    Executable: /Users/jerome/.../.venv/bin/python
    Valid: True

    System
    Platform: darwin
    OS: posix
    Python: 3.9.6
    Path: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9
    Executable: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9

    > poetry env use 3.12
    Creating virtualenv .../Users/jerome/.../.venv-coL99X6--py3.12 in /Users/jerome/Library/Caches/pypoetry/virtualenvs
    Using virtualenv: /Users/jerome/.../.venv

    > poetry env info

    Virtualenv
    Python: 3.9.6
    Implementation: CPython
    Path: /Users/jerome/.../.venv
    Executable: /Users/jerome/.../.venv/bin/python
    Valid: True

    System
    Platform: darwin
    OS: posix
    Python: 3.9.6
    Path: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9
    Executable: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9


    I have tried different alternatives of the poetry env use command, like telling it the exact path to the Python 3.12 executable (in Homebrew's path). With the same result.

    What did I miss?

    Continue reading...

Compartilhe esta Página