Specify project specific Python with Poetry23 Jan 2023
But I sometimes found Poetry failed to resolve the dependencies because of the unsupported Python version used by the environment. For example, it shows the following error message.
The currently activated Python version 3.7.14 is not supported by the project (^3.9). Trying to find and use a compatible version.
Some packages I used were not compatible with Python 3.7 in this case. But I was confused because my local PATH leads to Python 3.9 thanks to Pyenv. So how can I specify the project-specific python version?
The answer was simple. It needs to be more to specify the PATH by pyenv. We also need to set the python version by
env use subcommands.
$ poetry init --python 3.9 OR $ poetry env use 3.9
It tells the Poetry environment to use this Python version explicitly. With these settings, we can install all dependencies without any problem.