# List versions To see what’s on offer you can list all available python versions by running:
pyenv install -l
Install your favorite version of python with the command below.
pyenv install 3.12.0
# Create a virtualenv Change directory to the root of your project. Decide which version of python you want to use. Have a look at which version you have installed and are available to you.
pyenv versions system 3.12.3 3.12.3/envs/ai-env * ai-env --> /Users/david/.pyenv/versions/3.12.3/envs/ai-env (set by PYENV_VERSION environment variable)
You should see the version or versions here that you chose to install.
Next you can create a virtualenv with a version of choice. I usually have identical names for my projects, repositories and virtualenvs. I like to keep a clean 1 virtualenv per project / repository. This allows me to easily manage my dependencies.
pyenv virtualenv 3.12.0 myproject
This will create a virtualenv named “myproject” with python version 3.12.0. Next, activate the environment for your project by running.
pyenv local myproject
This will create a file named `.python-version` that contains the name of the virtualenv.
> Note: Make sure to never commit this file to git!
Now, your prompt should probably start with (myproject), unless you have configured your terminal in some funky customized way.
# Deleting environments If you want to delete a python environment use the project name as an argument in the following code.
pyenv virtualenv-delete myproject