Skip to content

Guide to Install the Latest Python Version and Poetry

Step 1: Install the Latest Python Version

Windows

  1. Download the latest Python installer:

  2. Run the installer:

    • Follow the instructions in the installer.
    • Make sure to check the box that says "Add Python to PATH".
  3. Verify the installation:

    • Open Command Prompt.
    • Run the following command to check the Python version:
      sh
      python --version
    • You should see the latest Python version displayed.

macOS

  1. Download the latest Python installer:

  2. Run the installer:

    • Follow the instructions in the installer.
    • Make sure to check the box that says "Add Python to PATH".
  3. Verify the installation:

    • Open Terminal.
    • Run the following command to check the Python version:
      sh
      python3 --version
    • You should see the latest Python version displayed.
  4. Set up Python alias:

    • Add the following line to your ~/.zshrc or ~/.bash_profile file:
      sh
      alias python=python3
    • Reload the terminal configuration:
      sh
      source ~/.zshrc  # or source ~/.bash_profile

Linux

  1. Update the package list:

    • Open Terminal.
    • Run the following command:
      sh
      sudo apt update
  2. Install Python:

    • Run the following command:
      sh
      sudo apt install python3
  3. Verify the installation:

    • Run the following command to check the Python version:
      sh
      python3 --version
    • You should see the latest Python version displayed.
  4. Set up Python alias:

    • Add the following line to your ~/.bashrc or ~/.zshrc file:
      sh
      alias python=python3
    • Reload the terminal configuration:
      sh
      source ~/.bashrc  # or source ~/.zshrc
  5. Other way to install Python on Linux is to use the deadsnakes PPA:

    • Run the following commands:
      sh
      sudo add-apt-repository ppa:deadsnakes/ppa
      sudo apt update
      sudo apt install python3.13  # Replace 3.10 with the desired version
    • Verify the installation:
      sh
      python3.13 --version  # Replace 3.10 with the installed version
      
      # set alias for the new Python version
      echo "alias python=python3.13" >> ~/.bashrc  # Replace 3.10 with the installed version
      echo "alias py=python3.13" >> ~/.bashrc  # Replace 3.10 with the installed version
      source ~/.bashrc  # Reload the terminal configuration
  6. Install pip (if not already installed):

    • Run the following command:
      sh
      sudo apt install python3-pip
    • Verify pip installation:
      sh
      pip3 --version
    • You should see the pip version displayed.

Step 2: Install Poetry

  1. Install Poetry:

    • Open a terminal or command prompt.
    • Run the following command to install Poetry:
      sh
      curl -sSL https://install.python-poetry.org | python3 -
  2. Configure your environment:

    • Add Poetry to your PATH by following the instructions provided after the installation.
    • Typically, you need to add the following line to your ~/.bashrc, ~/.zshrc, or equivalent file:
      sh
      export PATH="$HOME/.local/bin:$PATH"
    • Reload the terminal configuration:
      sh
      source ~/.bashrc  # or source ~/.zshrc
  3. Verify the installation:

    • Run the following command to check the Poetry version:
      sh
      poetry --version
    • You should see the Poetry version displayed.
  4. Optional: Enable Poetry tab completion:

    • Run the following command to enable tab completion:
      sh
      poetry completions zsh > ~/.zsh/completions/_poetry
    • Add the following line to your ~/.zshrc file:
      sh
      fpath+=~/.zsh/completions
      autoload -U compinit && compinit
    • Reload the terminal configuration:
      sh
      source ~/.zshrc