Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry env info has wrong virtualenv info #6893

Closed
4 tasks done
adammarples opened this issue Oct 26, 2022 · 6 comments · Fixed by #6986
Closed
4 tasks done

poetry env info has wrong virtualenv info #6893

adammarples opened this issue Oct 26, 2022 · 6 comments · Fixed by #6986
Labels
area/venv Related to virtualenv management kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@adammarples
Copy link

adammarples commented Oct 26, 2022

  • 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

Creating a fresh poetry environment, the info returned by poetry env info does not match the virtualenv created

  1. create a fresh dir
mkdir sample && cd sample
  1. check that my active python is as I want (3.10.3 installed using asdf)
> ~/sample $ python --version
Python 3.10.3
> ~/sample $ which python
/Users/adammarples/.asdf/installs/python/3.10.3/bin/python

2.5 make sure prefer-active-python is set to true

> ~/sample $ poetry config virtualenvs.prefer-active-python true
  1. poetry init, and manually changed suggested python compatible version from 3.9 to 3.10
> ~/sample $ poetry init
Compatible Python versions [^3.9]:  ^3.10
  1. poetry env info, no path so far, but declares that the Virtualenv is Python version 3.9.11
> ~/sample $ poetry env info
Virtualenv
Python:         3.9.11
Implementation: CPython
Path:           NA
Executable:     NA


System
Platform:   darwin
OS:         posix
Python:     3.9.11
Path:       /Users/adammarples/.pyenv/versions/3.9.11
Executable: /Users/adammarples/.pyenv/versions/3.9.11/bin/python3.9
  1. poetry update seems to create the correct virtualenv (3.10)
> ~/sample $ poetry update
Creating virtualenv sample-vPyTu8GS-py3.10 in /Users/xxxx/Library/Caches/pypoetry/virtualenvs
> ~/sample $ poetry run python --version
Python 3.10.3
> ~/sample $  poetry run which python
/Users/adammarples/Library/Caches/pypoetry/virtualenvs/sample-vPyTu8GS-py3.10/bin/python
  1. poetry env info, still no path, but declares that the Virtualenv is Python version 3.9.11
> ~/sample $ poetry env info
Virtualenv
Python:         3.9.11
Implementation: CPython
Path:           NA
Executable:     NA


System
Platform:   darwin
OS:         posix
Python:     3.9.11
Path:       /Users/adammarples/.pyenv/versions/3.9.11
Executable: /Users/adammarples/.pyenv/versions/3.9.11/bin/python3.9
@adammarples adammarples added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 26, 2022
@Superskyyy
Copy link

Superskyyy commented Nov 1, 2022

Same, this happens when .venv is removed from my project, resulting in NA in virtualenv info and poetry install will fail with Python not found. (Ubuntu)

I believe this problem is caused by the option prefer-active-python, when I turn that off, the virtual env can be recreated without errors.

@adammarples
Copy link
Author

I just want to add to this issue that suddenly poetry has found the right virtualenv but it has decided that all my poetry environments now direct to this sample environment 😂 I have no idea how but this is the output of poetry env info in now all of my projects.

Virtualenv
Python:         3.10.3
Implementation: CPython
Path:           /Users/adammarples/Library/Caches/pypoetry/virtualenvs/sample-vPyTu8GS-py3.10
Executable:     /Users/adammarples/Library/Caches/pypoetry/virtualenvs/sample-vPyTu8GS-py3.10/bin/python
Valid:          True

System
Platform:   darwin
OS:         posix
Python:     3.10.3
Path:       /Users/adammarples/.asdf/installs/python/3.10.3
Executable: /Users/adammarples/.asdf/installs/python/3.10.3/bin/python3.10

I'm assuming that this is the result of prefer-active-python, because that is the only setting I have changed. I just wish there was a dead simple way of getting poetry to build an environment from the active python interpreter in the shell at the time, I have rarely successfully managed to do this. I have all kinds of tools (pyenv, asdf, direnv) for managing which python version is active, I just want poetry to use it!

@doolio
Copy link
Contributor

doolio commented Nov 5, 2022

I have the same issue (see discussion #6978). I've found it works provided the currently active python matches the python used to install poetry.

@adammarples
Copy link
Author

Thank you @finswimmer !

@david-waterworth
Copy link

I just encountered this with a new project and after a bit of investigation, it turned out that vscode automatically activated a venv from another project and didn't provide any indication in the console. So when I ran poetry it was running in the wrong context. By deactivating the env that vscode activated poetry worked fine again.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/venv Related to virtualenv management kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants