Skip to content

Poetry env use <version> does not work and uses the default version #10655

@abompard

Description

@abompard

Description

I can't get the poetry env use command to work, it always creates a virtualenv with the default python.
This is with Poetry 2.1.4.

Here's an example on a clean project:

$ poetry init

This command will guide you through creating your pyproject.toml config.

Package name [testproject]:  
Version [0.1.0]:  
Description []:  
Author [REDACTED, n to skip]:  n
License []:  
Compatible Python versions [>=3.14]:  >=3.11

Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file

[project]
name = "testproject"
version = "0.1.0"
description = ""
authors = [
    {name = "Your Name",email = "[email protected]"}
]
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
]


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


Do you confirm generation? (yes/no) [yes] yes

Now here's what's going wrong (I think):

$ poetry env use 3.11
Creating virtualenv testproject-DmxhG7lM-py3.11 in /home/abompard/.cache/pypoetry/virtualenvs
Using virtualenv: /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11

$ poetry env info

Virtualenv
Python:         3.14.0
Implementation: CPython
Path:           /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11
Executable:     /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/python
Valid:          True

Base
Platform:   linux
OS:         posix
Python:     3.14.0
Path:       /usr
Executable: /usr/bin/python3.14

$ poetry run python -V
Python 3.14.0

And I do have 3.11 installed:

$ python3.11 -V
Python 3.11.14

I read the env use command documentation but I don't see what I'm doing wrong, so I think this is a bug.

Workarounds

When the env is created first, for example by tox, then poetry uses it properly and does not use the default version:

$ source .tox/py310/bin/activate
(py310) $ poetry env info

Virtualenv
Python:         3.10.19
Implementation: CPython
Path:           /home/abompard/REDACTED/.tox/py310
Executable:     /home/abompard/REDACTED/.tox/py310/bin/python
Valid:          True

Base
Platform:   linux
OS:         posix
Python:     3.10.19
Path:       /usr
Executable: /usr/bin/python3.10

Poetry Installation Method

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

Operating System

Fedora 43

Poetry Version

Poetry (version 2.1.4)

Poetry Configuration

cache-dir = "/home/abompard/.cache/pypoetry"
data-dir = "/home/abompard/.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/abompard/.local/share/pypoetry/python
repositories.test.url = "https://test.pypi.org/legacy/"
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/abompard/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.txt

Example pyproject.toml

[project]
name = "testproject"
version = "0.1.0"
description = ""
authors = [
    {name = "Your Name",email = "[email protected]"}
]
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
]


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

Poetry Runtime Logs

poetry-runtime.log
$ poetry -vvv env use /usr/bin/python3.11
Loading configuration file /home/abompard/.config/pypoetry/config.toml
Loading configuration file /home/abompard/.config/pypoetry/auth.toml
[findpython:findpython] Running script: ['/usr/bin/python3.11', '-EsSc', 'import platform; print(platform.python_version())']
[findpython:findpython] Running script: ['/usr/bin/python', '-EsSc', 'import sys; print(sys.executable)']
Found: /usr/bin/python
[findpython:findpython] Running script: ['/usr/bin/python', '-EsSc', 'import platform; print(platform.python_version())']
Creating virtualenv testproject-DmxhG7lM-py3.11 in /home/abompard/.cache/pypoetry/virtualenvs
[findpython:findpython] Running script: ['/usr/bin/python3.11', '-EsSc', 'import sys; print(sys.executable)']
[virtualenv:virtualenv.discovery.builtin] find interpreter for spec PythonSpec(path=/usr/bin/python3)
[virtualenv:virtualenv.info] filesystem is case-sensitive
[virtualenv:virtualenv.discovery.builtin] proposed PythonInfo(spec=CPython3.14.0.final.0-64, exe=/usr/bin/python3, platform=linux, version='3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)]', encoding_fs_io=utf-8-utf-8)
[virtualenv:virtualenv.discovery.builtin] accepted PythonInfo(spec=CPython3.14.0.final.0-64, exe=/usr/bin/python3, platform=linux, version='3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)]', encoding_fs_io=utf-8-utf-8)
[virtualenv:virtualenv.info] symlink on filesystem does work
[virtualenv:virtualenv.seed.embed.base_embed] The --no-wheel and --wheel options are deprecated. They have no effect for Python > 3.8 as wheel is no longer bundled in virtualenv.
[virtualenv:virtualenv.run.session] create virtual environment via CPython3Posix(dest=/home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11, clear=False, no_vcs_ignore=False, global=False)
[virtualenv:virtualenv.util.path._sync] create folder /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin
[virtualenv:virtualenv.util.path._sync] create folder /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib/python3.14/site-packages
[virtualenv:virtualenv.util.path._sync] create folder /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib64/python3.14/site-packages
[virtualenv:virtualenv.create.pyenv_cfg] write /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/pyvenv.cfg
[virtualenv:virtualenv.create.pyenv_cfg]        home = /usr/bin
[virtualenv:virtualenv.create.pyenv_cfg]        implementation = CPython
[virtualenv:virtualenv.create.pyenv_cfg]        version_info = 3.14.0.final.0
[virtualenv:virtualenv.create.pyenv_cfg]        virtualenv = 20.35.4
[virtualenv:virtualenv.create.pyenv_cfg]        include-system-site-packages = false
[virtualenv:virtualenv.create.pyenv_cfg]        base-prefix = /usr
[virtualenv:virtualenv.create.pyenv_cfg]        base-exec-prefix = /usr
[virtualenv:virtualenv.create.pyenv_cfg]        base-executable = /usr/bin/python3.14
[virtualenv:virtualenv.util.path._sync] symlink /usr/bin/python3 to /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/python
[virtualenv:virtualenv.create.via_global_ref.api] create virtualenv import hook file /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib/python3.14/site-packages/_virtualenv.pth
[virtualenv:virtualenv.create.via_global_ref.api] create /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib/python3.14/site-packages/_virtualenv.py
[virtualenv:virtualenv.run.session] ============================== target debug ==============================
[virtualenv:virtualenv.create.creator] debug via /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/python /usr/lib/python3.14/site-packages/virtualenv/create/debug.py
[virtualenv:virtualenv.run.session] {
[virtualenv:virtualenv.run.session]   "sys": {
[virtualenv:virtualenv.run.session]     "executable": "/home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/python",
[virtualenv:virtualenv.run.session]     "_base_executable": "/usr/bin/python3.14",
[virtualenv:virtualenv.run.session]     "prefix": "/home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11",
[virtualenv:virtualenv.run.session]     "base_prefix": "/usr",
[virtualenv:virtualenv.run.session]     "real_prefix": null,
[virtualenv:virtualenv.run.session]     "exec_prefix": "/home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11",
[virtualenv:virtualenv.run.session]     "base_exec_prefix": "/usr",
[virtualenv:virtualenv.run.session]     "path": [
[virtualenv:virtualenv.run.session]       "/usr/lib64/python314.zip",
[virtualenv:virtualenv.run.session]       "/usr/lib64/python3.14",
[virtualenv:virtualenv.run.session]       "/usr/lib64/python3.14/lib-dynload",
[virtualenv:virtualenv.run.session]       "/home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib64/python3.14/site-packages",
[virtualenv:virtualenv.run.session]       "/home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib/python3.14/site-packages"
[virtualenv:virtualenv.run.session]     ],
[virtualenv:virtualenv.run.session]     "meta_path": [
[virtualenv:virtualenv.run.session]       "<class '_virtualenv._Finder'>",
[virtualenv:virtualenv.run.session]       "<class '_frozen_importlib.BuiltinImporter'>",
[virtualenv:virtualenv.run.session]       "<class '_frozen_importlib.FrozenImporter'>",
[virtualenv:virtualenv.run.session]       "<class '_frozen_importlib_external.PathFinder'>"
[virtualenv:virtualenv.run.session]     ],
[virtualenv:virtualenv.run.session]     "fs_encoding": "utf-8",
[virtualenv:virtualenv.run.session]     "io_encoding": "utf-8"
[virtualenv:virtualenv.run.session]   },
[virtualenv:virtualenv.run.session]   "version": "3.14.0 (main, Oct 17 2025, 00:00:00) [GCC 15.2.1 20251022 (Red Hat 15.2.1-3)]",
[virtualenv:virtualenv.run.session]   "makefile_filename": "/usr/lib64/python3.14/config-3.14-x86_64-linux-gnu/Makefile",
[virtualenv:virtualenv.run.session]   "os": "<module 'os' (frozen)>",
[virtualenv:virtualenv.run.session]   "site": "<module 'site' (frozen)>",
[virtualenv:virtualenv.run.session]   "datetime": "<module 'datetime' from '/usr/lib64/python3.14/datetime.py'>",
[virtualenv:virtualenv.run.session]   "math": "<module 'math' from '/usr/lib64/python3.14/lib-dynload/math.cpython-314-x86_64-linux-gnu.so'>",
[virtualenv:virtualenv.run.session]   "json": "<module 'json' from '/usr/lib64/python3.14/json/__init__.py'>"
[virtualenv:virtualenv.run.session] }
[virtualenv:virtualenv.run.session] add seed packages via FromAppData(download=False, pip=bundle, via=copy, app_data_dir=/home/abompard/.local/share/virtualenv)
[virtualenv:virtualenv.app_data.via_disk_folder] got embed update of distribution pip from /home/abompard/.local/share/virtualenv/wheel/3.14/embed/3/pip.json
[virtualenv:virtualenv.seed.wheels.periodic_update] using periodically updated wheel /home/abompard/.local/share/virtualenv/wheel/house/pip-25.3-py3-none-any.whl
[virtualenv:virtualenv.seed.embed.via_app_data.via_app_data] install pip from wheel /home/abompard/.local/share/virtualenv/wheel/house/pip-25.3-py3-none-any.whl via CopyPipInstall
[filelock:filelock] Attempting to acquire lock 139893569233184 on /home/abompard/.local/share/virtualenv/wheel/3.14/image/1/CopyPipInstall/pip-25.3-py3-none-any.lock
[filelock:filelock] Lock 139893569233184 acquired on /home/abompard/.local/share/virtualenv/wheel/3.14/image/1/CopyPipInstall/pip-25.3-py3-none-any.lock
[filelock:filelock] Attempting to release lock 139893569233184 on /home/abompard/.local/share/virtualenv/wheel/3.14/image/1/CopyPipInstall/pip-25.3-py3-none-any.lock
[filelock:filelock] Lock 139893569233184 released on /home/abompard/.local/share/virtualenv/wheel/3.14/image/1/CopyPipInstall/pip-25.3-py3-none-any.lock
[virtualenv:virtualenv.util.path._sync] copy directory /home/abompard/.local/share/virtualenv/wheel/3.14/image/1/CopyPipInstall/pip-25.3-py3-none-any/pip to /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib/python3.14/site-packages/pip
[virtualenv:virtualenv.util.path._sync] copy directory /home/abompard/.local/share/virtualenv/wheel/3.14/image/1/CopyPipInstall/pip-25.3-py3-none-any/pip-25.3.dist-info to /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib/python3.14/site-packages/pip-25.3.dist-info
[virtualenv:virtualenv.util.path._sync] copy /home/abompard/.local/share/virtualenv/wheel/3.14/image/1/CopyPipInstall/pip-25.3-py3-none-any/pip-25.3.virtualenv to /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/lib/python3.14/site-packages/pip-25.3.virtualenv
[distlib:distlib.util] changing mode of /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/pip3.14 to 755
[distlib:distlib.util] changing mode of /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/pip to 755
[distlib:distlib.util] changing mode of /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/pip3 to 755
[distlib:distlib.util] changing mode of /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/bin/pip-3.14 to 755
[virtualenv:virtualenv.seed.embed.via_app_data.pip_install.base] generated console scripts pip-3.14 pip3 pip3.14 pip
[virtualenv:virtualenv.run.session] add activators for Bash, CShell, Fish, Nushell, PowerShell, Python
[virtualenv:virtualenv.create.pyenv_cfg] write /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11/pyvenv.cfg
[virtualenv:virtualenv.create.pyenv_cfg]        home = /usr/bin
[virtualenv:virtualenv.create.pyenv_cfg]        implementation = CPython
[virtualenv:virtualenv.create.pyenv_cfg]        version_info = 3.14.0.final.0
[virtualenv:virtualenv.create.pyenv_cfg]        virtualenv = 20.35.4
[virtualenv:virtualenv.create.pyenv_cfg]        include-system-site-packages = false
[virtualenv:virtualenv.create.pyenv_cfg]        base-prefix = /usr
[virtualenv:virtualenv.create.pyenv_cfg]        base-exec-prefix = /usr
[virtualenv:virtualenv.create.pyenv_cfg]        base-executable = /usr/bin/python3.14
[virtualenv:virtualenv.create.pyenv_cfg]        prompt = testproject-py3.11
Using virtualenv: /home/abompard/.cache/pypoetry/virtualenvs/testproject-DmxhG7lM-py3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expectedstatus/external-issueIssue is caused by external project (platform, dep, etc)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions