Create Poetry virtual environment (venv) using specific Python version
Firstly you need to have installed specific python version in your system, for example we need Python 3.9 (meanwhile 3.10 and 3.11 already available)
Install specific python version #
brew install python@3.9
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.9
Install specific version installer from the official Python website and then create symlink to this version
cd $HOME\appdata\local\programs\python
copy python39\python.exe python39\python3.9.exe
Create environment #
poetry env use python3.9
python3.9 it is actual path to the Python executable, in case if it does not exists in your PATH you need to specify full path to the executable based on your OS.
This is a bit different from other package managers but to create venv you should to have pyproject.toml file in current directory, otherwise you need to initialize project first.