Pylerno
English

macOS installation

Install the interpreter, create an isolated workspace, and verify your first script in Terminal.

On this page

Install Python

  1. Open Python downloads for macOS and choose a stable Python 3 release, version 3.12 or newer.
  2. Download the macOS installer compatible with your Mac. Open the .pkg, follow Continue and Install, and finish the installer.
  3. Open a new Terminal window from Applications → Utilities. Enter python3 --version. If it reports an older version, try the version-specific command for the runtime you installed, such as python3.14 --version. Use that command to create the environment below.

Create your workspace

sh
mkdir -p ~/python-study
cd ~/python-study
python3 -m venv .venv
.venv/bin/python -c "import sys; print(sys.executable); print(sys.prefix != sys.base_prefix)"

Look for a path ending in .venv/bin/python, followed by True. These tell you exactly which interpreter ran and whether it belongs to a virtual environment.

Save and run a file

From this folder, enter nano hello.py or open a plain-text editor and save a file named hello.py here. Enter the Python line below. In nano, press Ctrl+O, Enter, then Ctrl+X to save and return to Terminal. Run the shell command below it.

python
print("Python is ready")
sh
.venv/bin/python hello.py

The expected result is Python is ready. If the file cannot be found, use pwd and ls to check your folder and filename. Build your first local project.

Check your understanding

Which command creates a virtual environment named .venv on macOS?

Choose one answer

Search documentation

Share this page