Installing Python
To write Python code, we first need to install the Python Interpreter. This is the software that reads your code and translates it into instructions your computer’s processor can execute.
We will be installing the latest stable version of Python 3.
Installation Steps
Section titled “Installation Steps”Windows does not come with Python pre-installed. You will need to download the official installer.
-
Download: Go to python.org/downloads and click the big button to download the latest version (e.g., Python 3.12+).
-
Run the Installer: Double-click the downloaded
.exefile. -
CRITICAL STEP: Check the box that says “Add python.exe to PATH”.
If you miss this step, you will not be able to run Python from the command line efficiently.
-
Install: Click “Install Now” and wait for the process to finish.
-
Disable Path Length Limit (Optional): If prompted, you can disable the path length limit to avoid issues with long file paths later.
macOS often comes with an older version of Python, but for development, we want the latest version managed by us. The best way is to use Homebrew.
- Open Terminal: Press
Cmd + Space, type “Terminal”, and hit Enter. - Check for Homebrew: Type
brew --version. If it says “command not found”, install it from brew.sh. - Install Python: Run the following command:
Terminal window brew install python - This will install the latest version (usually accessed as
python3).
Most Linux distributions come with Python 3 pre-installed. However, you should ensure you have the necessary development tools.
Debian / Ubuntu:
sudo apt updatesudo apt install python3 python3-venv python3-pipFedora:
sudo dnf install python3Verifying the Installation
Section titled “Verifying the Installation”Once the installation is complete, you need to verify that your terminal can “see” Python.
- Open your command line tool (Command Prompt, PowerShell, or Terminal).
- Type one of the following commands and press Enter:
python --version# ORpython3 --versionExpected Output:
You should see something like Python 3.12.1.
What is PIP?
Section titled “What is PIP?”When you installed Python, you also installed pip (Package Installer for Python). This is the tool we will use later to install third-party libraries (like pandas or requests).
Verify it works:
pip --version# ORpip3 --version