← Back to Platform Selector | Home
Other platforms: Windows | Linux
We recommend Python 3.13+ for the best experience. Python 3.13 has dramatically better error messages that explain what went wrong in plain English, making debugging much easier for beginners.
Option A (python.org installer):
- Download from Python releases for macOS.
- Run the installer package.
Option B (Homebrew, if installed):
brew install pythonOpen Terminal and verify:
python3 --version
python3 -c "print('hello from python')"Expected output:
Python 3.x.x
hello from python
Why
python3? macOS includes an older system Python. Always usepython3to get the version you installed.
Option A (recommended): VS Code
Install VS Code, then add these extensions:
Option B (absolute beginners): Thonny
Thonny is a Python IDE designed for beginners. It comes with Python built in, has a simple interface, and includes a debugger that lets you step through code line by line. If VS Code feels overwhelming, start with Thonny and switch to VS Code later.
mkdir -p "$HOME/python_sme/projects" "$HOME/python_sme/templates" "$HOME/python_sme/notes"uv is a modern, fast replacement for pip and venv. It is used throughout this curriculum.
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --versionExpected output: uv x.x.x (version number).
If you prefer pip: All
uvcommands in this curriculum have pip equivalents. Replaceuv venvwithpython3 -m venv .venvanduv pip installwithpip install. Everything else stays the same.
cd "$HOME/python_sme/projects"
mkdir -p hello_sme
cd hello_sme
uv venv
source .venv/bin/activate
python --versionExpected output:
- Prompt starts with
(.venv). - Python version prints.
pip fallback: Replace
uv venvwithpython3 -m venv .venv.
uv pip install pytest
pytest --versionpip fallback: Replace
uv pip install pytestwithpython -m pip install pytest.
Expected output: pytest version is displayed.
Create hello.py:
print("Hello, Future Python SME")Create test_hello.py:
def test_math_baseline():
assert 1 + 1 == 2Run:
python hello.py
pytest -qExpected output:
Hello, Future Python SME
1 passed
Do not embed database credentials in scripts. Use environment variables:
export APP_DB_HOST="your-sql-host"
export APP_DB_NAME="your_db"
export APP_DB_USER="your_sql_login"Rules: keep passwords/tokens out of source code. Keep .env and secret files in .gitignore. Prefer approved enterprise secret storage when available. Use least privilege and read-only credentials first.
After completing this guide you should have:
- A working
hello_smeproject withhello.py,test_hello.py, and.venv. python hello.pysucceeds.pytest -qsucceeds.- You can explain your credential safety rules.
python3not found: Reopen Terminal. Confirm install finished. Reinstall Python.- macOS shows old system Python: Always use
python3instead ofpython. uvnot found: Re-run the install command from Step 4. Or fall back to pip.pytestnot found: Confirm venv is active. Runuv pip install pytest(orpip install pytest).
- Deactivate venv and run
pytestto see failure mode. - Rename
test_hello.pytohello_test.pyand observe discovery behavior. - Intentionally misspell
assertand read the traceback. - Switch interpreter in VS Code, then switch back to the project venv.
- Add a fake credential directly in code, then remove it and replace with env var access.
- Thonny (beginner-friendly Python IDE)
- Automate the Boring Stuff
- Python Tutor
| ← Platform Selector | Home | Next → |
|---|