Problem: poetry does not pick up the current 'local' python (set via pyenv)
pyenv is a nice Python version management tool.
Problem: it can happen that poetry does not pick up the current local Python version.
For example, if the global version is 3.11.7, then pyenv can be used to set the local version:
pyenv local 3.12.7
Then, using poetry (here it is used to run ruff, to format):
poetry run ruff format
There is an error, as the poetry environment is still using the global Python version:
Current Python version (3.11.7) is not allowed by the project (^3.12).
Please change python executable via the "env use" command.
Solution:
poetry env use python
This creates a new poetry environment, which picks up the local Python version.
The new environment needs its dependencies installed:
poetry install
Now, poetry should run OK:
poetry run ruff format
Comments
Post a Comment