1. Install the target version

pyenv install 3.11.3

2. Shell into this specific python version

pyenv shell 3.11.3

3. Use this python version to create virtualenv in current directory

python -m venv .venv

…or use virtualenv:

virtualenv .venv -p $(pyenv which python)

Package management: pdm

  • pyenv global should be set to something other than system