Guide to Install the Latest Python Version and Poetry
Step 1: Install the Latest Python Version
Windows
Download the latest Python installer:
- Go to the official Python website.
- Download the Windows installer.
Run the installer:
- Follow the instructions in the installer.
- Make sure to check the box that says "Add Python to PATH".
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
Download the latest Python installer:
- Go to the official Python website.
- Download the macOS installer.
Run the installer:
- Follow the instructions in the installer.
- Make sure to check the box that says "Add Python to PATH".
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.
Set up Python alias:
- Add the following line to your
~/.zshrcor~/.bash_profilefile:shalias python=python3 - Reload the terminal configuration:sh
source ~/.zshrc # or source ~/.bash_profile
- Add the following line to your
Linux
Update the package list:
- Open Terminal.
- Run the following command:sh
sudo apt update
Install Python:
- Run the following command:sh
sudo apt install python3
- Run the following command:
Verify the installation:
- Run the following command to check the Python version:sh
python3 --version - You should see the latest Python version displayed.
- Run the following command to check the Python version:
Set up Python alias:
- Add the following line to your
~/.bashrcor~/.zshrcfile:shalias python=python3 - Reload the terminal configuration:sh
source ~/.bashrc # or source ~/.zshrc
- Add the following line to your
Other way to install Python on Linux is to use the
deadsnakesPPA:- 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
- Run the following commands:
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.
- Run the following command:
Step 2: Install Poetry
Install Poetry:
- Open a terminal or command prompt.
- Run the following command to install Poetry:sh
curl -sSL https://install.python-poetry.org | python3 -
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:shexport PATH="$HOME/.local/bin:$PATH" - Reload the terminal configuration:sh
source ~/.bashrc # or source ~/.zshrc
Verify the installation:
- Run the following command to check the Poetry version:sh
poetry --version - You should see the Poetry version displayed.
- Run the following command to check the Poetry version:
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
~/.zshrcfile:shfpath+=~/.zsh/completions autoload -U compinit && compinit - Reload the terminal configuration:sh
source ~/.zshrc
- Run the following command to enable tab completion: