Introduction
In this lesson, you'll transition from learning about Python to actively running Python code on your computer. You will:
- Install Python on Windows, macOS, and Linux using official sources
- Configure environment variables so you can run
pythonfrom any terminal - Verify your installation using simple commands and a test script
- Compare popular IDEs and editors for Python
- Set up and customize an IDE, focusing on VS Code and PyCharm
- Install and manage essential tools:
pip, virtual environments, and package managers
By the end of this lesson, your system will be ready for hands-on coding throughout the course.
Installing Python on Different Operating Systems
We prioritize official distributions to avoid broken or outdated installations.
Windows
- Visit the official download page: Python for Windows
- Download the latest stable Python 3.x installer (64-bit).
- Run the installer, making sure to:
- Check
Add Python 3.x to PATH(this is crucial).
- Check
- Choose Customize installation if you prefer, but default options are safe.
- Complete the installation process.
macOS
macOS comes with a system Python that's often outdated and reserved for the OS. Install your own version:
- Visit Python for macOS
- Download the latest macOS 64-bit universal2 installer.
- Open the
.pkgfile and follow the installation wizard. - Post-installation, Python is usually available as
python3andpip3.
Note: You can also use Homebrew (
brew install python), but we'll assume you use the official installer unless otherwise specified.
Linux (Ubuntu / Debian-based and Others)
Most Linux distributions include Python, but you might need development-friendly versions.
- Check existing Python:
python3 --version - Ubuntu / Debian install or update:
sudo apt update sudo apt install python3 python3-pip - Fedora / RHEL:
sudo dnf install python3 python3-pip
Configuring Environment Variables and Verifying Installation
Checking Python from the Command Line
Open a terminal (Command Prompt / PowerShell on Windows, Terminal on macOS/Linux) and run:
python --version
If that fails (commonly on macOS/Linux), try:
python3 --version
You should see something like:
Python 3.12.1
Fixing PATH on Windows (if needed)
If python is not recognized:
- Know the exact location where Python installed
- Press
Winkey, search for Environment Variables. - Open Edit the system environment variables → Environment Variables….
- Under User variables, select
Path→ Edit. - Add entries similar to below or you location where python installed:
C:\Users\<YourUser>\AppData\Local\Programs\Python\Python312\C:\Users\<YourUser>\AppData\Local\Programs\Python\Python312\Scripts\
- Click OK on all dialogs, restart your terminal, and run
python --versionagain.
Running a Simple Test Script
Create a file named test_setup.py and add:
import sys
print("Python is working!")
print("Version:", sys.version)
print("Executable:", sys.executable)
Run it from the terminal in the folder where the file is saved:
python test_setup.py
Expected output:
Python is working!
Version: 3.12.1 (tags/...)
Executable: C:\Users\YourUser\AppData\Local\Programs\Python\Python312\python.exe
This confirms Python runs correctly and shows which interpreter you are using.
Summary / Key Takeaways
In this lesson, you have learned how to:
- Install Python from official sources on Windows, macOS, and Linux to avoid outdated system versions.
- Configure and verify your Python installation using PATH settings and test scripts from the command line.
- Confirm Python is working correctly by creating and running small test programs from both the terminal and IDE.
