foreach-ui logo
codeLanguages
account_treeDSA

Quick Actions

quizlock Random Quiz
trending_uplock Progress
  • 1
  • 2
  • 3
  • 4
  • quiz
Python
  • Download and install Python on your operating system
  • Understand the difference between Python versions
  • Set up a code editor or IDE for Python development
  • Verify your Python installation

Installing Python and Setting Up Your Environment

Getting Started

Before writing any Python code, you need Python installed on your machine. This is straightforward - we'll walk through the process for Windows, macOS, and Linux. The whole thing takes maybe 10 minutes, including setting up an editor.


Downloading Python

Where to Get It

Download Python from the official website only:


                                                          
             https://www.python.org/downloads/            
                                                          

Don't use third-party download sites. They might bundle unwanted software or, worse, modified versions.

Which Version

What to Choose Recommendation
Python 3.x Yes - always
Python 2.x No - unsupported since 2020
Latest stable version Usually your best bet

The website detects your operating system and suggests the right download automatically.


Installation by Operating System

Windows Installation


              Windows Installation Steps                  

                                                          
  1. Download the Windows installer (.exe)               
                                                          
  2. Run the installer                                    
                                                          
  3. IMPORTANT: Check "Add Python to PATH"               
                                                          
  4. Click "Install Now"                                  
                                                          
  5. Wait for installation to complete                    
                                                          
  6. Click "Close"                                        
                                                          

The "Add Python to PATH" checkbox is critical. If you miss it, you'll have to manually add Python to your system PATH later - doable but annoying.

macOS Installation

Option 1: Official Installer

  1. Download the macOS installer (.pkg) from python.org
  2. Double-click the downloaded file
  3. Follow the installation wizard
  4. Python will be installed to /Library/Frameworks/Python.framework/

Option 2: Using Homebrew (Recommended for developers)

# Install Homebrew first if you don't have it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Then install Python
brew install python

Linux Installation

Most Linux distributions come with Python pre-installed! Check first:

python3 --version

If not installed or you need a newer version:

Distribution Command
Ubuntu/Debian sudo apt update && sudo apt install python3
Fedora sudo dnf install python3
Arch Linux sudo pacman -S python

Verifying Your Installation

After installation, let's confirm everything works.

Open Your Terminal/Command Prompt

Operating System How to Open
Windows Search "cmd" or "PowerShell"
macOS Applications → Utilities → Terminal
Linux Ctrl + Alt + T

Check Python Version

Type one of these commands:

python --version
# or
python3 --version

Expected output:

Python 3.12.0   # (or similar version number)

Check pip (Package Installer)

pip --version
# or
pip3 --version

Expected output:

pip 23.2.1 from /path/to/pip (python 3.12)

Test the Interactive Shell

Type python or python3 to enter the interactive mode:


                Python Interactive Shell                  

                                                          
  $ python3                                               
  Python 3.12.0 (main, Oct  2 2023, 00:00:00)            
  >>> print("Hello, Python!")                            
  Hello, Python!                                          
  >>> 2 + 2                                               
  4                                                       
  >>> exit()                                              
                                                          

Type exit() or press Ctrl+D (Mac/Linux) or Ctrl+Z then Enter (Windows) to exit.


Setting Up Your Code Editor

You can write Python in Notepad if you want, but a proper code editor makes life much easier.

Popular Options

Editor Best For Cost
VS Code All-around development Free
PyCharm Professional Python development Free (Community) / Paid (Pro)
IDLE Beginners (comes with Python) Free
Jupyter Notebook Data science, learning Free
Sublime Text Lightweight editing Free / Paid

Recommended: Visual Studio Code


              Why VS Code?                                

                                                          
  • Free and open-source                                 
  • Excellent Python extension                           
  • Built-in terminal                                    
  • IntelliSense (smart code completion)                 
  • Debugging support                                    
  • Git integration                                      
  • Huge extension marketplace                           
                                                          

Setup VS Code for Python:

  1. Download from https://code.visualstudio.com/
  2. Install VS Code
  3. Open VS Code
  4. Go to Extensions (Ctrl+Shift+X)
  5. Search for "Python"
  6. Install the official Python extension by Microsoft

Alternative: PyCharm

PyCharm is built specifically for Python. It's heavier than VS Code but has more Python-specific features out of the box:

  1. Download from https://www.jetbrains.com/pycharm/
  2. Choose Community Edition (free)
  3. Install and follow the setup wizard
  4. Create a new project and select your Python interpreter

Understanding pip

pip is Python's package manager. When you need a library that's not built into Python, you use pip to install it.

# Install a package
pip install package_name

# Install a specific version
pip install package_name==1.0.0

# Upgrade a package
pip install --upgrade package_name

# List installed packages
pip list

# Uninstall a package
pip uninstall package_name

Common Packages You'll Use Eventually

Package Purpose
requests HTTP requests
numpy Numerical computing
pandas Data analysis
matplotlib Data visualization
flask Web development

Setting Up Your First Project Folder

Having an organized workspace saves headaches later:

my_python_projects/

 learning/
    lesson_01/
    lesson_02/

 practice/
    exercises/

 projects/
     my_first_project/

Create this structure:

# Windows (Command Prompt)
mkdir my_python_projects
cd my_python_projects
mkdir learning practice projects

# macOS/Linux
mkdir -p my_python_projects/{learning,practice,projects}

Troubleshooting Common Issues

"python" is not recognized

Problem: Command prompt doesn't recognize python

Solutions:

OS Solution
Windows Reinstall Python with "Add to PATH" checked
Windows Manually add Python to system PATH
macOS/Linux Use python3 instead of python

Multiple Python Versions

If you have multiple versions installed:

# Check available versions
python --version
python3 --version

# On Windows, use the py launcher
py -3.12 --version  # Specific version
py -3 --version     # Latest Python 3

pip not working

# Try these alternatives
pip3 install package_name
python -m pip install package_name
python3 -m pip install package_name

Key Takeaways


                   Remember These Points                  

                                                          
  • Download Python from python.org only                 
                                                          
  • Always use Python 3 (not Python 2)                   
                                                          
  • Windows: Check "Add Python to PATH"                  
                                                          
  • Verify with: python --version                        
                                                          
  • pip = Package installer for Python                   
                                                          
  • VS Code or PyCharm = Great editor choices            
                                                          

What's Next

You're all set up. Python is installed, your editor is ready, and you've got a workspace organized. Next lesson, we'll write your first Python program - starting with the classic "Hello, World!" and moving beyond it.

© 2026 forEach. All rights reserved.

Privacy Policy•Terms of Service