How to install Python using pyenv¶
Installing and using Python as recommended below has major benefits and will prevent problems in the future.
Windows: use the python.org version!
pyenv was created for macOS and Linux, and although it has a Windows version (called "pyenv-win"), this is not working very well and the installation is buggy.
Therefore, for Windows we recommend you install Python "the normal way" (downloading from python.org), but we strongly recommend you use virtual environments.
We recommend installing and managing Python using "pyenv". pyenv is a tool that allows you to install multiple versions of Python, and select which specific version should be used.
Step 2: Using pyenv, install Python 3.10.5
This will install Python 3.10.5; on macOS and Linux you can omit the minor version (the.5
at the end) and pyenv will automatically choose the latest version.
(Optional) What version of Python should I install?
How do I know which Python version I need? Generally it's recommended to use the previous version of Python (so if Python 3.11 is the latest, install 3.10). This is because it takes some time for libraries to be updated, so it's safer to use a version of Python which is more supported.
You can use pyenv install -l
to get a list of all available Python versions`
Step 3: Check what version of Python is currently the default Python
If you already have a pre-installed Python, this will printsystem
. It might also say "No Python version has been set yet". You can use this command anytime you want to check what version of Python is active.
Step 4: Set your newly installed Python as default
This command sets your newly installed Python as the default Python for all terminals.