Python
Setting up a flexible Python development environment is crucial, especially when working with projects that may require different Python versions. Instead of manually installing different Python versions, we recommend using pyenv, which allows for easy installation and management of multiple Python versions.
macOS Setup
Section titled “macOS Setup”-
Install Homebrew (if you haven’t already…Just go here) for instructions
-
Install pyenv using Homebrew
Once Homebrew is installed, you can install
pyenv:Terminal window brew install pyenv -
Configure pyenv
Add the following to your shell profile (
~/.bash_profile,~/.zshrc, etc.):Terminal window if command -v pyenv 1>/dev/null 2>&1; theneval "$(pyenv init --path)"fiThen, restart your terminal or run
source ~/.bash_profile(or your respective shell profile file). -
Install Python using pyenv
With
pyenvconfigured, you can install any Python version. For example, to install Python 3.9.1:Terminal window pyenv install 3.9.1
Windows Setup
Section titled “Windows Setup”Common pyenv Commands
Section titled “Common pyenv Commands”Listing Installed Python Versions
Section titled “Listing Installed Python Versions”To see a list of Python versions you have installed:
pyenv versionsSwitching Between Python Versions
Section titled “Switching Between Python Versions”If you’ve installed multiple Python versions, you can easily switch between them:
pyenv global [version]Replace [version] with the desired version number, e.g., pyenv global 3.9.1.
Setting a Local Python Version
Section titled “Setting a Local Python Version”To set a Python version for a specific project directory:
pyenv local [version]