Dev In The Mountain Header
A Developer In The mountains having fun

Installing Python

Before you can start programming in Python, you need to install it on your computer. This guide will walk you through the installation process for different operating systems.

Check if Python is Already Installed

Many computers come with Python pre-installed. Let's check if you already have it:

On Windows

  1. Open Command Prompt (press Win + R, type cmd, press Enter)
  2. Type python --version or python -V
  3. If Python is installed, you'll see something like Python 3.11.5

On macOS

  1. Open Terminal (press Cmd + Space, type "Terminal", press Enter)
  2. Type python3 --version
  3. If Python is installed, you'll see the version number

On Linux

  1. Open Terminal
  2. Type python3 --version
  3. Most Linux distributions come with Python pre-installed

Installing Python

Windows Installation

  1. Download Python

  2. Run the Installer

    • Double-click the downloaded file
    • Important: Check "Add Python to PATH" before clicking Install
    • Choose "Install Now" for default installation
    • Wait for installation to complete
  3. Verify Installation

    • Open Command Prompt
    • Type python --version
    • You should see the Python version you just installed

macOS Installation

Option 1: Official Installer

  1. Go to python.org/downloads
  2. Download the macOS installer
  3. Run the installer and follow the prompts
  4. Verify by typing python3 --version in Terminal

Option 2: Using Homebrew (Recommended)

  1. Install Homebrew if you don't have it:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Install Python:
    brew install python
    
  3. Verify installation:
    python3 --version
    

Linux Installation

Ubuntu/Debian:

sudo apt update
sudo apt install python3 python3-pip

CentOS/RHEL/Fedora:

sudo yum install python3 python3-pip

or for newer versions:

sudo dnf install python3 python3-pip

Arch Linux:

sudo pacman -S python python-pip

Understanding pip

When you install Python, you also get pip (Python Package Installer). This tool allows you to install additional Python packages and libraries.

Verify pip Installation

# Windows
pip --version

# macOS/Linux
pip3 --version

Common pip Commands

# Install a package
pip install package_name

# Install a specific version
pip install package_name==1.2.3

# List installed packages
pip list

# Upgrade a package
pip install --upgrade package_name

# Uninstall a package
pip uninstall package_name

Python Version Considerations

Python 2 vs Python 3

  • Python 2 reached end of life on January 1, 2020
  • Python 3 is the current and future of Python
  • Always use Python 3 for new projects
  • This tutorial series focuses on Python 3

Choosing a Python 3 Version

  • Latest Stable: Generally recommended for new learners
  • Python 3.8+: Supports most modern features
  • Python 3.10+: Includes the latest syntax improvements

Virtual Environments (Optional but Recommended)

Virtual environments help you manage dependencies for different projects. Here's a quick setup:

Using venv (Built-in)

# Create a virtual environment
python -m venv myproject

# Activate it
# Windows:
myproject\Scripts\activate
# macOS/Linux:
source myproject/bin/activate

# Deactivate when done
deactivate

Using conda (Alternative)

# Install Miniconda from https://docs.conda.io/en/latest/miniconda.html
# Create environment
conda create --name myproject python=3.11

# Activate
conda activate myproject

# Deactivate
conda deactivate

Troubleshooting Common Issues

"Python is not recognized" (Windows)

  • Python wasn't added to PATH during installation
  • Reinstall Python and check "Add Python to PATH"
  • Or manually add Python to your system PATH

Permission Errors (macOS/Linux)

  • Use python3 instead of python
  • Use pip3 instead of pip
  • For system-wide installs, you might need sudo (not recommended for packages)

Multiple Python Versions

  • Use python3 and pip3 to be explicit
  • Consider using virtual environments
  • On Windows, you can use the Python Launcher: py -3

Testing Your Installation

Create a simple test file to ensure everything works:

  1. Open a text editor
  2. Type: print("Hello, Python!")
  3. Save as test.py
  4. Run it:
    python test.py
    
  5. You should see: Hello, Python!

What's Next?

Now that you have Python installed, you're ready to:

Recommended Resources


Having trouble with installation? The Python community is very helpful - try searching for your specific error message or asking on forums like Stack Overflow or Reddit's r/learnpython.

More places to find me
Mental Health
follow me on Mastodon