🛠️ Setup Python
Getting Python installed on your computer is easier than you might think! Whether you're using Windows, macOS, or Linux, you'll have Python up and running in just a few minutes.
A proper setup means you can write and run Python programs without any headaches. Let's get started!
🔍 Check if Python is Already Installed
First, let's see if Python is already on your computer. Open your terminal or command prompt and try these commands:
🪟 Installing Python on Windows
Step 1: Download Python
- Go to python.org
- Click "Download Python" (gets the latest version)
- Save the installer file
Step 2: Run the Installer
⚠️ CRITICAL: Check the box "Add Python to PATH" before clicking Install!
This is the most important step - it lets you run Python from anywhere on your computer.
Step 3: Verify Installation
Open Command Prompt and type:
python --version
pip --version
Both commands should show version numbers.
Installing Python on macOS
Option 1: Official Installer (Recommended for Beginners)
- Go to python.org
- Download the macOS installer
- Run the installer (follow default settings)
Option 2: Using Homebrew
If you have Homebrew installed:\
brew install python3
📝 Important macOS Notes
- Use
python3
command (notpython
) - Use
pip3
command (notpip
) - Your system Python stays safe alongside the new Python
✅ Verify Installation
Open Terminal and type:
python3 --version
pip3 --version
🐧 Installing Python on Linux
Most Linux systems have Python 3, but let's make sure you have the latest version and pip.
Ubuntu/Debian:
sudo apt update
sudo apt install python3 python3-pip
CentOS/RHEL:
sudo yum install python3 python3-pip
Fedora:
sudo dnf install python3 python3-pip
✅ Verify Installation
python3 --version
pip3 --version
📦 Understanding pip (Package Installer)
pip stands for "Pip Installs Packages" - it's Python's package installer that comes with Python.
🛠️ Essential pip Commands:
pip install package_name # Install a package
pip list # Show installed packages
pip --version # Check pip version
📝 Setting Up a Code Editor
You can write Python in any text editor, but a good code editor makes everything easier!
🌟 Recommended: Visual Studio Code
Why VS Code is perfect for beginners:
- Free and easy to use
- Great Python support
- Built-in terminal
- Helpful error highlighting
Download: code.visualstudio.com
🔧 Other Good Options:
- PyCharm Community: Free, Python-focused
- IDLE: Comes with Python (simple but limited)
📁 Creating Your First Python Project
Let's set up a proper workspace for your Python learning:
📂 1. Create a Project Folder
Create a folder in your Documents directory called python-projects
:
Windows: Documents\python-projects
macOS/Linux: Documents/python-projects
📄 2. Create Your First Python File
Inside your project folder, create a file called hello.py
Important: Python files must end with .py
!
# Save this as hello.py in your python-projects folder:
print("=== MY FIRST PYTHON PROGRAM ===")
name = "Python Learner"
print(f"Hello, {name}!")
# Simple math
favorite_number = 7
doubled = favorite_number * 2
print(f"Your favorite number doubled: {doubled}")
# Fun with text
message = "I'm learning Python!"
print(message.upper())
print(f"Message length: {len(message)} characters")
print("Setup complete! 🐍")
▶️ Running Python Programs
There are several ways to run your Python code:
Method 1: Command Line
Navigate to your project folder and run:
# Windows
python hello.py
# macOS/Linux
python3 hello.py
Method 2: VS Code
- Open your
.py
file in VS Code - Click the ▶️ play button
- Or press F5
Method 3: IDLE
- Open IDLE (comes with Python)
- File → Open your
.py
file - Run → Run Module (or F5)
Method 4: Interactive Shell (REPL)
Type python
or python3
to start Python interactively:
>>> print("Hello World!")
Hello World!
>>> 2 + 2
4
>>> exit()
Common Setup Problems & Solutions
Problem: "Python is not recognized" (Windows)
Solution: Reinstall Python and check "Add Python to PATH"
Problem: Permission errors during installation
Solution: Run installer as Administrator (Windows) or use sudo
(Linux/macOS)
Problem: Multiple Python versions confusion
Solution: Always use python3
and pip3
on macOS/Linux
Problem: pip not working
Solution: Try python -m pip
instead of just pip
✅ What You've Accomplished
Congratulations! You now have:
- Python 3 installed and working
- pip package installer ready
- A code editor set up
- Your first Python project folder
- Knowledge of how to run Python programs
You're ready to start programming!
Test Your Knowledge
Test your understanding of Python setup:
What's Next?
Perfect! Python is installed and you're ready to code. Next, let's write your first real Python program and learn the basics of Python programming.
Continue to: Your First Program
Ready to start coding? Let's go! 🚀
Was this helpful?
Track Your Learning Progress
Sign in to bookmark tutorials and keep track of your learning journey.
Your progress is saved automatically as you read.