Janik von Rotz


1 min read

Manage Python versions with pyenv

With pyenv you can easily switch between python versions. When working on multiple project is recommended to create a .python-version file containing the targeted node version. Here is how.

First make sure the right python version is installed.

➜  example-project git:(main) python --version
Python 3.7.8
➜  example-project git:(main) pyenv install 3.8.6
Installing Python-3.8.6...
Installed Python-3.8.6 to /home/janikvonrotz/.pyenv/versions/3.8.6  

Use the new version locally.

➜  example-project git:(main) pyenv local 3.8.6
➜  example-project git:(main) ✗ cat .python-version
3.8.6

Of course you can set the new version globally using pyenv global x.x.x.

Switch between folders to check if the correct version is loaded automatically.

➜  ~ python --version 
Python 3.7.8
➜  example-project git:(main) ✗ python --version
Python 3.8.6

Here is an overview of the python version is selected when working with pyenv.

You can reset the global version by setting system as python version.

➜  ~ echo system > ~/.pyenv/version

Categories: Python
Tags: python , pyenv , version management
Edit this page
Show statistic for this page