Python Tutorial for Beginners 1: Install and Setup for Mac and Windows
Table of Contents
Introduction
This tutorial will guide you through the installation and setup of Python on both Mac and Windows operating systems. By the end of this guide, you'll have a working Python environment and be ready to write your first script.
Step 1: Install Python on Mac
-
Download Python
- Visit the official Python website: python.org
- Click on the "Download Python" button for the latest version.
-
Run the Installer
- Open the downloaded
.pkg
file. - Follow the installation prompts. Make sure to check the box that says "Add Python to PATH" during installation.
- Open the downloaded
-
Verify the Installation
- Open the Terminal.
- Type
python3 --version
and press Enter. You should see the installed Python version.
-
Install Pip (if not included)
- Pip is a package manager for Python. To check if it’s installed, type
pip3 --version
in Terminal. - If not installed, run:
sudo easy_install pip
- Pip is a package manager for Python. To check if it’s installed, type
Step 2: Install Python on Windows
-
Download Python
- Go to the official Python website: python.org
- Click on the "Download Python" button for the latest version.
-
Run the Installer
- Open the downloaded
.exe
file. - Ensure you check the box that says “Add Python to PATH” before clicking “Install Now.”
- Open the downloaded
-
Verify the Installation
- Open Command Prompt.
- Type
python --version
and press Enter. You should see the installed Python version.
-
Install Pip (if not included)
- Pip usually comes with Python installations. To check, type
pip --version
in Command Prompt. - If it's not installed, download
get-pip.py
from the official site and run:python get-pip.py
- Pip usually comes with Python installations. To check, type
Step 3: Setting Up a Code Editor
-
Choose a Code Editor
- Options include Sublime Text, Atom, or any preferred IDE.
- For Sublime Text, download it from sublimetext.com and install it.
-
Configure the Editor
- Open Sublime Text or your chosen editor.
- Create a new file and save it with a
.py
extension to indicate it's a Python script.
Step 4: Create and Run Your First Python Script
-
Write a Simple Script
- Open your code editor and create a new file named
hello.py
. - Add the following code:
print("Hello, World!")
- Open your code editor and create a new file named
-
Run Your Script
- On Mac: Open Terminal, navigate to the script's directory using
cd
command, and run:python3 hello.py
- On Windows: Open Command Prompt, navigate to the script's directory, and run:
python hello.py
- On Mac: Open Terminal, navigate to the script's directory using
-
Check Output
- You should see "Hello, World!" printed in the terminal or command prompt.
Conclusion
You have successfully installed Python on both Mac and Windows, set up a code editor, and run your first Python script. From here, you can explore more advanced Python tutorials and begin developing your programming skills. Consider checking out the full Python Beginner Series for more comprehensive learning. Happy coding!