Get AI summaries of any video or article — Sign up free
Python Tutorial for Beginners 1: Install and Setup for Mac and Windows thumbnail

Python Tutorial for Beginners 1: Install and Setup for Mac and Windows

Corey Schafer·
5 min read

Based on Corey Schafer's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Install Python 3.6 from python.org rather than relying on a preinstalled Python 2.7 on macOS.

Briefing

Getting Python running on your computer is the whole point of this beginner setup walkthrough—and it’s handled separately for Mac and Windows, then unified into the same “write code, run code” workflow. On macOS, Python 2.7 often comes preinstalled, so the key step is installing Python 3 from python.org and making sure the terminal’s `python` command points to Python 3 (via a shell alias). On Windows, the essential move is installing Python 3.6 and selecting the installer option to “add Python to PATH,” so the `python` command works immediately in Command Prompt.

After installation, the tutorial shifts from setup to first contact with Python itself. Typing `python` in a terminal or Command Prompt opens an interactive prompt where code runs one line at a time. A simple `print('Hello World')` demonstrates output, and assigning a variable like `x = 10` followed by `print(x)` shows that values can be stored and retrieved interactively. The interactive mode is positioned as useful for quick tests, not for building real programs.

To write a multi-line program, the tutorial uses a plain text editor and demonstrates Python file creation with IDLE—the editor that ships with Python. In IDLE, creating a new file, writing `print('Hello World')`, and saving it as something like `intro.py` sets up a script that can be run from the command line by calling `python intro.py` (from the directory where the file lives). A short detour shows how inline comments work: lines starting with `#` are ignored by Python at runtime, serving only as notes for humans reading the code.

From there, the workflow expands beyond IDLE. The tutorial notes that beginners can stick with IDLE and run scripts from the command line, but for heavier use it recommends upgrading to a more capable editor or IDE. Examples include Sublime Text and Atom as text editors with extra functionality, and JetBrains PyCharm as a full IDE with features like debugging. The tutorial also demonstrates that Sublime Text can run the same `intro.py` file directly through its build/run commands.

The practical takeaway is a complete path from “Python not ready” to “Hello World runs reliably”: install the correct Python 3 version, ensure the command-line entry point works (`python` maps to Python 3 on macOS; PATH is set on Windows), then choose whether to code in IDLE or a preferred editor and run scripts from the terminal. The next step promised is fundamentals—starting with variables and the string data type.

Cornell Notes

This setup guide walks through installing Python 3.6 on both macOS and Windows, then using it to run code in two ways: an interactive prompt and a saved script file. On macOS, Python 2.7 may be preinstalled, so Python 3.6 is installed from python.org and a bash alias is used so the `python` command runs Python 3. On Windows, Python 3.6 is installed and the installer option to add Python to PATH is selected so Command Prompt recognizes `python`. After installation, `python` opens an interactive REPL for one-line tests, while IDLE (or another editor like Sublime Text) is used to create multi-line `.py` files such as `intro.py` that run via `python intro.py`. Comments starting with `#` are ignored at runtime.

Why does macOS often show Python 2.7 first, and how does the setup fix that?

macOS commonly has an older `python` command available (often Python 2.7). The guide installs Python 3.6 from python.org, then checks versions using `python --version` and `python3 --version`. Because the terminal may still map `python` to Python 2.7, it adds a bash alias in the bash profile (using Nano) so `python` points to `python3`—specifically `alias python=Python 3`—and then rechecks that `python --version` reports Python 3.6.

What’s the difference between the interactive prompt and running a script file?

Typing `python` in the terminal/Command Prompt starts an interactive prompt (REPL) where code executes one line at a time, such as `print('Hello World')` or `x = 10` followed by `print(x)`. For multi-line programs, the guide exits the prompt with `exit()` and instead creates a `.py` file (e.g., `intro.py`) in IDLE or another editor, then runs it from the command line with `python intro.py`.

How does the guide ensure Windows can run `python` from Command Prompt?

On Windows, the guide installs Python 3.6 from python.org and emphasizes selecting the installer checkbox to “add Python to PATH.” Without that, Command Prompt may show `python is not recognized`. After installation, it verifies by reopening Command Prompt and running `python --version`, which should display Python 3.6.

Where does IDLE fit into the beginner workflow?

IDLE is the editor that comes with Python. The guide uses IDLE to create a new file, write `print('Hello World')`, save it as `intro.py` (on the desktop in the example), and then run it from the terminal/Command Prompt. IDLE itself initially opens an interactive-style environment, but using File → New File creates a real script that can be executed.

What happens to comments in Python scripts?

Inline comments start with `#`. The guide adds a comment line describing what the code does, saves the file, and reruns it; the output remains unchanged. That demonstrates that comments are ignored by Python at runtime and exist only for developers reading the code.

Why might a beginner switch from IDLE to another editor like Sublime Text or PyCharm?

IDLE works for basic scripts, but the guide suggests upgrading when programming more seriously. Sublime Text and Atom are presented as popular text editors with extra functionality, while PyCharm is described as a full IDE with features such as debugging a running application. The guide also shows running the same `intro.py` from Sublime Text via Tools → Build.

Review Questions

  1. What steps on macOS ensure that typing `python` runs Python 3.6 instead of Python 2.7?
  2. When would you choose the interactive prompt over creating a `.py` file?
  3. How does selecting “add Python to PATH” change what happens when you type `python` in Windows Command Prompt?

Key Points

  1. 1

    Install Python 3.6 from python.org rather than relying on a preinstalled Python 2.7 on macOS.

  2. 2

    On macOS, verify versions with `python --version` and `python3 --version`, then use a bash alias so `python` maps to Python 3 if needed.

  3. 3

    On Windows, select the installer option to add Python to PATH so Command Prompt recognizes the `python` command.

  4. 4

    Use the interactive prompt for quick one-line tests, but create `.py` files for multi-line programs.

  5. 5

    Create and run scripts by saving a file like `intro.py` and executing it with `python intro.py` from the correct directory.

  6. 6

    Use `#` for comments; they are ignored at runtime and won’t affect program output.

  7. 7

    Consider upgrading from IDLE to editors/IDEs like Sublime Text, Atom, or PyCharm for more features such as debugging.

Highlights

macOS may keep `python` pointed at Python 2.7 even after Python 3.6 is installed, so a bash alias can redirect `python` to `python3`.
On Windows, the single checkbox “add Python to PATH” determines whether `python` works in Command Prompt immediately.
The interactive prompt is ideal for quick experiments, while IDLE (or another editor) is used to build runnable `.py` scripts.
Comments beginning with `#` are for humans only—Python ignores them when executing code.
Sublime Text can run the same `.py` script directly from within the editor, producing the same output as the command line.

Topics

  • Python Installation
  • macOS Setup
  • Windows PATH
  • Interactive Prompt
  • IDLE and Scripts
  • Text Editors
  • PyCharm

Mentioned