Question about use case of combination with pyenv and poetry #8738
-
I'm using poetry and pyenv together to switch between different Python versions. I have a question though. If the globally set Python version is higher than the version specified for a poetry project, an error occurs unless I use poetry env use. For example, my global Python version is 3.12.0, and the Python version for the poetry project is 3.10.12. After creating a
So, I resolved the issue by explicitly specifying full-path of the Python 3.10.12 version using the poetry env use command. However, I noticed that if the globally set Python version is lower than the version specified for a poetry project, no such error occurs. For instance, if the global Python version is 3.10.12 and the pyproject.toml file of the poetry project specifies Python 3.12.0, running the poetry shell command works without any errors. I'm curious about the reason for this difference. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Poetry assumes that the virtual environment it will build will be compatible with the project if the global Python version is lower than the one provided in the project. This is due to the fact that higher Python versions often preserve backward compatibility, thus executing a project with a higher Python version should work in principle. Poetry alerts you about the probable conflict in the first instance you specified, where the general Python version is 3.12.0 and the project requires 3.10.12. There is no warning in the second instance, when the global Python version is 3.10.12 and the project requires 3.12.0, since Poetry thinks that adopting a higher version would still be compatible. |
Beta Was this translation helpful? Give feedback.
Poetry assumes that the virtual environment it will build will be compatible with the project if the global Python version is lower than the one provided in the project. This is due to the fact that higher Python versions often preserve backward compatibility, thus executing a project with a higher Python version should work in principle.
Poetry alerts you about the probable conflict in the first instance you specified, where the general Python version is 3.12.0 and the project requires 3.10.12. There is no warning in the second instance, when the global Python version is 3.10.12 and the project requires 3.12.0, since Poetry thinks that adopting a higher version would still be compatible.