Setting up your computer for Python programming is the essential first step in your journey. This guide covers installation on Windows, macOS, and Linux, plus how to configure your development environment properly.

Why Is the Correct Environment Configuration Important?

A properly configured environment prevents common issues like compatibility problems and confusing error messages that can frustrate beginners. The right tools also increase your productivity and make using third-party libraries much easier.

A clean installation ensures that Python commands work from any folder in your terminal, allowing you to follow advanced tutorials without issues. Follow each step carefully for the best results.

Installing Python on Windows

Windows is one of the most popular operating systems among programming beginners. Follow these steps to install Python correctly:

Step 1: Download the Installer

Visit python.org and click the "Downloads" button. The site will automatically recommend the latest stable version for Windows.

Step 2: Add Python to PATH

Run the installer. Important: Before clicking "Install Now", check the box that says "Add python.exe to PATH". This allows your terminal to recognize Python commands from any folder. If you skip this, you'll need to manually configure environment variables later.

Step 3: Complete Installation

Click "Install Now" and wait for it to finish. If prompted, click "Disable path length limit" to prevent issues with long file paths, then click "Close".

Step 4: Verify Installation

Open Command Prompt or PowerShell and type:

python --version

If you see the version number (like Python 3.13.x), the installation was successful.

Installing Python on macOS

Mac computers often come with Python pre-installed, but it's usually an old version (Python 2.7, which is deprecated). You need to install a current version separately.

Using Homebrew

Homebrew is the recommended package manager for macOS. If you don't have it, install it from brew.sh, then run:

brew install python3

Homebrew will download and configure Python without affecting the system Python.

Verify macOS Installation

Restart Terminal and type:

python3 --version

Note: On macOS, you typically use python3 instead of python.

Installing Python on Linux

Most Linux distributions (Ubuntu, Fedora, Mint) come with Python pre-installed. Verify your installation with:

Check Current Version

python3 --version

Install on Ubuntu/Debian

If you need to install or update Python and pip:

sudo apt update
sudo apt install python3 python3-pip

Choosing a Code Editor

With Python installed, you need a code editor or IDE to write and run your programs.

Visual Studio Code (VS Code)

VS Code is the most popular choice among developers. It's free, lightweight, and has excellent Python support through extensions.

To configure VS Code for Python:

  1. Download and install VS Code from code.visualstudio.com
  2. Open the Extensions tab (Ctrl+Shift+X)
  3. Search for "Python" (by Microsoft) and install it
  4. The extension enables running code, debugging, and IntelliSense

PyCharm

PyCharm is a powerful IDE for professional developers. The free Community Edition includes everything needed for Python development, including virtual environment support.

Virtual Environments

Virtual environments allow you to isolate dependencies for each project. This prevents conflicts when different projects need different versions of the same library.

Create an isolated environment with venv:

# Create virtual environment
python -m venv myenv

# Activate on Windows
myenv\Scripts\activate

# Activate on Mac/Linux
source myenv/bin/activate

When activated, you'll see the environment name in your terminal prompt.

First Python Script

Let's verify everything works by creating and running your first Python program:

Step 1: Open your code editor and create a new file.

Step 2: Save it as hello.py

Step 3: Type the following code:

greeting = "Hello, Python Universe!"
number = 10 + 25

print(greeting)
print(f"Result: {number}")

Step 4: Run the script:

python hello.py

If you see the output, your environment is ready!

Next Steps

With your environment configured, you're ready to learn Python fundamentals. We recommend:

Practice consistently and you'll make rapid progress!