Skip to content

Latest commit

 

History

History
117 lines (83 loc) · 2.79 KB

File metadata and controls

117 lines (83 loc) · 2.79 KB

Installation of Multiple Python Interpreter Versions

Installing Python in Windows

Download the versions you desire from here: https://www.python.org/downloads/windows/

Select the following options (if available):

  • Add python.exe to PATH Screenshot 1

  • Customize installation

    • Maintain the defaults for 'Documentation', 'pip', 'tcl/tk and IDLE', and 'Python test suite', i.e., Enabled Screenshot 2
    • Maintain the defaults for 'py launcher' and 'for all users', i.e., Disabled

Under advanced options:

  • Enable 'Install Python for all users', 'Create shortcuts for installed applications', 'Add Python to environment variables', 'Precompile standard library'
  • Choose a clear path, preferably one without spaces, example, C:\Python312\ instead of C:\Program Files\Python312 Screenshot 3

Install Python in Linux

Install Dependencies

sudo apt update
sudo apt install -y \
  build-essential \
  libssl-dev \
  zlib1g-dev \
  libbz2-dev \
  libreadline-dev \
  libsqlite3-dev \
  libncursesw5-dev \
  xz-utils \
  tk-dev \
  libxml2-dev \
  libxmlsec1-dev \
  libffi-dev \
  liblzma-dev
sudo apt install git

Install pyenv

curl https://pyenv.run | bash

Edit ~/.bashrc

vim ~/.bashrc

Add:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"

Restart the terminal and confirm that pyenv is installed:

pyenv --version

Install the Python Version you Desire

Example:

pyenv install 3.12.10
pyenv install 3.14.3

Confirm the Python version installed

pyenv versions

Set the global and local defaults

Global default:

pyenv global 3.12.10

Example of setting the local default (per project):

cd my_project
pyenv local 3.12.0

Confirm the global Python version installed

python --version

Installing Python in MacOS

Download the versions you desire from here: https://www.python.org/downloads/macos/