Python is one of the most popular programming languages used for web development, data analysis, artificial intelligence, and more. Below are the step-by-step instructions to download and install the latest version of Python 3 on your operating system.
1. Check Your Current Python Version
Before installing, check if Python is already installed on your system:
- Open a terminal or command prompt.
- Type the command:
python --version
or
python3 --version
If Python is already installed, it will display the version. If not, proceed with the installation steps below.
2. Download Python 3
- Visit the Official Python Website:
- Go to https://www.python.org/downloads/.
- Choose the Latest Version:
- The website will automatically suggest the latest Python version suitable for your operating system.
- Example: “Download Python 3.12.2” (the version might vary depending on the release).
- Download the Installer:
- Click the Download button to save the installer file to your computer.
3. Install Python 3
For Windows:
- Run the Installer:
- Locate the downloaded file (e.g.,
python-3.x.x.exe
) and double-click to run it.
- Locate the downloaded file (e.g.,
- Add Python to PATH:
- On the first screen, check the box labeled “Add Python to PATH”.
- This step is crucial for running Python from the command line.
- Install Now:
- Click “Install Now” to proceed with the default installation.
- Verify Installation:
- Open Command Prompt.
- Type:
python --version
or
python3 --version
- The installed Python version should be displayed.
For macOS:
- Run the Installer:
- Open the downloaded
.pkg
file and follow the installation prompts.
- Open the downloaded
- Add Python to PATH (Optional):
- macOS may already include Python 2.x, so you might need to use
python3
to access the installed version.
- macOS may already include Python 2.x, so you might need to use
- Verify Installation:
- Open Terminal and type:
python3 --version
- The installed Python version should be displayed.
- Open Terminal and type:
For Linux:
- Check Pre-installed Python:
- Many Linux distributions come with Python pre-installed.
- Check by typing:
python3 --version
- Install Python Using a Package Manager:
- If Python is not installed, install it using your distribution’s package manager:
sudo apt update sudo apt install python3
- For Red Hat-based systems:
sudo yum install python3
- If Python is not installed, install it using your distribution’s package manager:
- Verify Installation:
- Type:
python3 --version
- Type:
4. Install pip (Python Package Manager)
Pip is included by default in recent versions of Python. To check if pip is installed:
pip --version
If pip is missing, install it using:
python -m ensurepip
5. Test Python Installation
- Open a terminal or command prompt.
- Enter the Python interactive shell by typing:
python
or
python3
- Run a simple command:
print("Hello, Python!")
6. Optional: Install an IDE
For coding in Python, you may install an Integrated Development Environment (IDE):
- Popular IDEs:
- PyCharm
- Visual Studio Code
- Jupyter Notebook
- Thonny