python-poetry / python-poetry/poetry

`poetry env info` doesn't show env created with another python version

Open
#7,190 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • Poetry version: Poetry (version 1.3.0)

  • Python version: 3.10.8

  • OS version and name: Fedora 37 Silverblue

  • pyproject.toml: Open below:

    [tool.poetry]
    name = "test2"
    version = "0.1.0"
    description = ""
    authors = []
    readme = "README.md"
    
    [tool.poetry.dependencies]
    python = "~3.8"
    
    
    [build-system]
    requires = ["poetry-core"]
    build-backend = "poetry.core.masonry.api"
    
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I have Poetry running under python 3.10. I have python 3.8 interpreter available too. As you see, the project is restricted to python 3.8. However, it just won't display the created virtualenv unless explicitly activated. See this terminal session:

➤ poetry run true
The currently activated Python version 3.10.8 is not supported by the project (~3.8).
Trying to find and use a compatible version. 
Using python3.8 (3.8.16)
Creating virtualenv test2-6GjfYUOb-py3.8 in /var/home/yajo/.cache/pypoetry/virtualenvs

➤ poetry run which python
/var/home/yajo/.cache/pypoetry/virtualenvs/test2-6GjfYUOb-py3.8/bin/python

➤ poetry env info

Virtualenv
Python:         3.10.8
Implementation: CPython
Path:           NA
Executable:     NA

System
Platform:   linux
OS:         posix
Python:     3.10.8
Path:       /nix/store/nzgqxw4d875pgl1lji8n3q82x3bf7ldi-python3-3.10.8
Executable: /nix/store/nzgqxw4d875pgl1lji8n3q82x3bf7ldi-python3-3.10.8/bin/python3.10

➤ poetry env info --path

# Now I do enable 3.8 manually, it starts returning the expected values
➤ poetry env use 3.8
Using virtualenv: /var/home/yajo/.cache/pypoetry/virtualenvs/test2-6GjfYUOb-py3.8

➤ poetry env info

Virtualenv
Python:         3.8.16
Implementation: CPython
Path:           /var/home/yajo/.cache/pypoetry/virtualenvs/test2-6GjfYUOb-py3.8
Executable:     /var/home/yajo/.cache/pypoetry/virtualenvs/test2-6GjfYUOb-py3.8/bin/python
Valid:          True

System
Platform:   linux
OS:         posix
Python:     3.8.16
Path:       /nix/store/zzfhcf101498slkcfgi085jqd33rjf95-python3-3.8.16
Executable: /nix/store/zzfhcf101498slkcfgi085jqd33rjf95-python3-3.8.16/bin/python3.8

➤ poetry env info --path
/var/home/yajo/.cache/pypoetry/virtualenvs/test2-6GjfYUOb-py3.8

It should work, even without having to enable the specific environment by hand.

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

Start by reproducing the sequence using poetry run, poetry env info, and poetry env info --path with an incompatible active Python and a compatible project interpreter. Trace how poetry env info selects the environment after poetry run creates it; done means it reports the created Python 3.8 virtualenv without requiring poetry env use 3.8 first.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.