-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
venv created with the wrong python version #4646
Comments
I have the same issue on MacOS, Poetry 1.2.0a2, and pyenv 2.1.0. |
I am experiencing the same issue. pyenv: 2.2.0 Relevant Python versions are different from @asafalon1 , but the gist is basically the same: Python binaries of the created env. are of wrong version:
The concept of activated version is not quite clear, poetry must use the version specified in the .toml file for purposes of creating environment. What is activated version? I understand, it might make sense to select between variants of the same version (e.g. Python 3.9.7 from brew and Python 3.9.7 from pyenv), but why poetry may be using completeyl different version? Documentation was not very helpful for me. |
I recommend closing this issue as a duplicate of #1888 (with same workaround). |
@Kurt-von-Laven this issue is different in the gist. The problem #1888 you are referring to, is about creating a new environment, where the behaviour is not ideal as well and not perfectly documented (in terms of which version of Python to expect in pyproject.toml). This issue however is about a different situation when pyproject.toml already exists and has a desired version of Python in it. |
I realize the scenarios aren't all exactly identical, but I believe in all cases a new virtual environment is being created, which is the salient point here. They do, after all, have precisely the same workaround that you and I arrived at independently. #651 and #4187 are related as well. In the former, the creator of Poetry explains that the wrong Python version being used in these virtual environments is an unfortunate side effect of an intentional change that they would like to keep for its maintenance and security benefits. |
From what i'm reading the other issues describe other symptoms of the same change, but the bug described here is different, so connecting is them is fine, but I dont think they are all the same issue, or should be closed as one. The workaround is nice, by the way, but its impractical on my end, I have over 30 repos i work on, with different python versions, ranging from 3.6 to 3.10. |
This has proven to be a complete nightmare, at least for me. I cannot, by any means, get poetry to stop using
A plain python call uses the correct version
In the toml project file I have
I have no idea what else to try. |
|
Closing this for now as it overlaps with multiple feature requests (automatic Pyenv version selection) as well as fixes that have gone in (respect the activated |
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. |
I am on the latest Poetry version.
I have searched the issues of this repo and believe that this is not a duplicate.
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).OS version and name: macOS Big Sur (11.6)
Poetry version: 1.1.11
Issue
I have both versions 3.7.2 and 3.8.0 of python installed on my mac.
My .toml states the python version should be 3.7:
...
[tool.poetry.dependencies]
python = "~3.7"
...
When i run "poetry update" (I use zsh terminal, don't know if it matters or not) a venv is created for my project (good), its name is myproj-DbOwq67j-py3.7 (also good), but the actual files created are python 3.8 (not good!). If you navigate to that folder you can clearly see the folder name is 3.7 but the file names are 3.8. Also I had issues installing packages that can only be installed on 3.7, so no doubt this is not just a naming issue.
This is bad as it is, because that venv is forever broken unless I patch the poetry code that creates venvs, but even after patching I get another issue:
Every time I close the terminal and reopen it, I run "poetry shell" to run commands for that venv, and i get this:
➜ myproj git:(master) ✗ poetry shell
The currently activated Python version 3.8.0 is not supported by the project (~3.7).
Trying to find and use a compatible version.
Using python3 (3.7.2)
The virtual environment found in /Library/Frameworks/Python.framework/Versions/3.8 seems to be broken.
Recreating virtualenv myproj-DbOwq67j-py3.7 in /Users/[my user]/Library/Caches/pypoetry/virtualenvs/myproj-DbOwq67j-py3.7
Spawning shell within /Users/[my user]/Library/Caches/pypoetry/virtualenvs/myproj-DbOwq67j-py3.7
➜ myproj git:(master) ✗ . /Users/[my user]/Library/Caches/pypoetry/virtualenvs/myproj-DbOwq67j-py3.7/bin/activate
(myproj-DbOwq67j-py3.7) ➜ myproj git:(master) ✗
Which means that the venv will be recreated once more with the wrong python version and override my patching. Also I need to reinstall all packages which in this case takes like 800s. Not fun.
By the way, the version in /Library/Frameworks/Python.framework/Versions/3.8 is definitely not broken, so i don't know what that is about.
The text was updated successfully, but these errors were encountered: