Setup & Hello World Jump to this section
This page will help you get started with Python. You’ll learn two easy ways to try Python and run a small example to make sure everything is working.
Two easy ways to try Python Jump to this section
You have two simple choices. Pick the one that feels best for you.
-
Option A: Run Python in your browser (easiest):
- Use the playground on these pages. It runs code in the browser so you do not need to install anything.
- Best for following lessons, trying examples, and doing exercises quickly.
-
Option B: Install Python on your computer (good for projects):
- Install Python when you want to save files, use other libraries, or build projects on your machine.
Below are step-by-step, beginner-friendly instructions for each major operating system.
Windows (step-by-step) Jump to this section
- Open a web browser and go to https://python.org/downloads/
- Click the latest "Download" button for Windows and run the installer file you downloaded.
- IMPORTANT: On the first installer screen, check the box that says "Add Python to PATH".
- Click "Install Now" and follow the prompts.
How to check it worked:
python --version
# or, if that doesn't work:
py -3 --version
Quick tips:
- To open a terminal: press the Windows key, type "cmd" (Command Prompt) or "PowerShell", and press Enter.
- If
pythonis not found, trypy -3or rerun the installer and make sure "Add Python to PATH" was checked.
macOS (step-by-step) Jump to this section
Option 1 (Homebrew, for people who already use Homebrew):
brew update
brew install python
python3 --version
Option 2 (official installer):
- Go to https://python.org/downloads/ and download the macOS installer.
- Open the downloaded package and follow the installer steps.
How to check it worked:
python3 --version
Quick tips:
- To open a terminal: press Command+Space, type "Terminal", then press Enter.
- On macOS you often use
python3instead ofpython.
Linux (step-by-step examples) Jump to this section
Debian/Ubuntu (open Terminal and run):
sudo apt update
sudo apt install -y python3 python3-venv python3-pip
python3 --version
Fedora (open Terminal and run):
sudo dnf install -y python3 python3-venv python3-pip
python3 --version
Arch (open Terminal and run):
sudo pacman -Syu python
python --version
Quick tips:
- To open a terminal: look for "Terminal" in your app launcher or press Ctrl+Alt+T.
- Use
python3andpip3if your system keeps thepythonname for Python 2.
Creating & Running a File Jump to this section
The Python terminal can only run one line of code at a time. When creating projects, you're going to want to put it in an actual file.
To do this, open a text editor such as Python IDLE and create a Python file (for example, hello.py)
Then, in your Python terminal, navigate to where that file is stored (for example, cd C:\Users\YourUsername\Desktop on Windows or cd /YourUsername/Desktop on Mac/Linux)
Now, you can run python3 hello.py to run your file. The output will appear in the terminal.
Hello World Jump to this section
Put this code into hello.py or paste it into the playground and run it:
print("Hello, world!")
If it outputs 'Hello, world!', you are ready to move on!
Troubleshooting Common Setup Problems Jump to this section
If something doesn't work, don't worry; try the simple checks below.
Windows Jump to this section
-
Problem: the
pythoncommand says "not recognized".-
Try
py -3 --versionfirst. If that works, Python is installed butpythonmight not be on PATH. -
Re-run the Windows installer and make sure you checked "Add Python to PATH".
-
To see where Windows finds Python, open Command Prompt and run:
where python
-
-
Problem:
pipwon't run or gives permission errors.-
Run these to make sure pip is available and up to date:
python -m ensurepip --upgrade python -m pip install --upgrade pip
-
-
Problem: PowerShell won't let you run the activate script.
-
Open PowerShell as Administrator and run once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -
Then activate your venv with:
.\venv\Scripts\Activate.ps1
-
macOS Jump to this section
-
Problem:
pythonruns Python 2 orpythonisn't found.- Use
python3andpip3:python3 --versionandpython3 -m pip install <package>.
- Use
-
Problem: permission errors when installing packages.
-
Use a virtual environment (recommended) or install packages for your user:
python3 -m pip install --user <package>
-
Linux Jump to this section
-
Problem: your distribution provides an old Python.
-
On Ubuntu you can add the deadsnakes PPA to install newer versions (example for 3.11):
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install -y python3.11 python3.11-venv python3.11-distutils
-
-
Problem:
venvorpipis missing after install.-
Install the helper packages (Debian/Ubuntu example):
sudo apt install python3-venv python3-pip
-
-
Problem: permission errors when installing packages globally.
-
Use a virtual environment or the
--userflag:python3 -m pip install --user <package>
-
If you still see an error, you can try copying the full error text and searching it up.
