| layout | default |
|---|---|
| title | Setup |
| nav_order | 4 |
| has_children | true |
| permalink | /setup/ |
| course_lesson | true |
| course_index | 00 |
| next_page | /lessons/fundamentals/ |
| next_title | Python Fundamentals |
This page helps you install Python, create one file, and see your first successful output. Complete the quick start before learning about virtual environments.
If you use a school or office computer, ask a parent, teacher, or administrator before installing software. Do not remove a Python installation that already belongs to the operating system.
You need:
- a computer running Windows, macOS, or Linux;
- permission to install software;
- a text editor;
- a terminal, which is a window where you type commands.
Choose only the section for your operating system.
Use the official Python Install Manager instructions. It can be installed from Python.org or the Microsoft Store.
After installation, open PowerShell from the Start menu and type:
python --versionIf your installation uses the py command, this also works:
py --versionYou should see a Python 3 version. The exact numbers may be newer than examples in this course.
mkdir python-learning
cd python-learningmkdircreates a folder.cdmoves the terminal into that folder.
Open the python-learning folder in your editor. Create a file named hello.py and type:
print("Hello, Python!")Save the file. Return to PowerShell and run:
python hello.pyIf python does not work but py does, run:
py hello.pyExpected output:
Hello, Python!
Download the current supported Python 3 installer from Python Releases for macOS. Use the normal .pkg installer and complete its instructions.
Open Terminal and type:
python3 --versionYou should see a Python 3 version. Do not delete or modify Python supplied by macOS or Apple development tools.
mkdir python-learning
cd python-learningOpen the python-learning folder in your editor. Create hello.py:
print("Hello, Python!")Save it and run:
python3 hello.pyExpected output:
Hello, Python!
Python 3 is already available on many Linux distributions. First try:
python3 --versionIf Python is unavailable on Debian or Ubuntu, use:
sudo apt update
sudo apt install python3 python3-venv python3-pipFor Fedora, Arch, or another distribution, use its package manager and the official Python Unix guide.
Create the learning folder:
mkdir python-learning
cd python-learningCreate hello.py in your editor:
print("Hello, Python!")Save it and run:
python3 hello.pyhello.py -> Python reads the file -> print() displays text -> terminal shows output
hello.pyis a Python source file..pyis the usual filename ending for Python code.python,py, orpython3starts the Python interpreter.- An interpreter is the program that reads and runs Python instructions.
If you saw Hello, Python!, pause and enjoy that small win. Your computer has successfully run your code.
A virtual environment is a private project box for Python tools and installed packages. One project's packages will not interfere with another project's packages.
computer Python
├── project A .venv -> project A packages
└── project B .venv -> project B packages
The Basic examples use the standard library and can run without extra packages. Creating .venv now is still a useful habit.
From inside python-learning:
python3 -m venv .venv
source .venv/bin/activate
python --versionFrom inside python-learning:
python -m venv .venv
.venv\Scripts\Activate.ps1
python --versionIf you normally use py, create it with:
py -m venv .venvWhen activation succeeds, the terminal prompt normally begins with (.venv). Activation makes the plain python command select the environment's interpreter.
To leave the environment later:
deactivate
If PowerShell blocks activation, do not randomly weaken computer security. You may run the environment directly:
.venv\Scripts\python.exe hello.pyRead Editor Setup. Any editor that saves plain .py files is acceptable. IDLE, which is included with many Python installations, is enough for this course.
Read Terminal Basics. You only need a few commands to move between folders and run files.
- A Python 3 version command works.
- The
python-learningfolder exists. -
hello.pycontains the one-line program. - Running the file displays
Hello, Python!. - I know which command works on my computer:
python,py, orpython3. - I either created
.venvor understand that I can return to that optional step.
If a checkpoint fails, open Setup Troubleshooting.