Installing Python and Setting Up Your Environment (Windows / Mac / Linux)
Introduction
Before you can start writing Python code, you need to install Python and set up a development environment on your computer. This lesson will guide you step-by-step through the process for Windows, macOS, and Linux. By the end, you’ll be ready to write and run your first Python program.
What You'll Learn
- How to download and install Python on Windows, Mac, or Linux
- How to verify your Python installation
- How to write and run Python code
- Recommended code editors and IDEs for beginners
- Online Platforms for Running Python Code
Step 1: Download Python
Visit the official Python website:
https://www.python.org/downloads
The website will auto-detect your OS and suggest the latest version. Always install the latest Python 3 release.
Installing Python on Windows
1. Download Installer
- Click the Download Python button
- Save the .exe file
2. Run the Installer
- Double-click the file
- Check "Add Python to PATH"
- Click Install Now
3. Verify Installation
python --version
Expected output:
Python 3.12.x
Installing Python on macOS
1. Download Installer
Install Python
- Open the .pkg file
- Follow on-screen instructions
Verify Installation
python3 --version
Expected output:
Python 3.12.x
Installing Python on Linux
Ubuntu/Debian
sudo apt update
sudo apt install python3
python3 --version
Fedora
sudo dnf install python3
python3 --version
Arch Linux
sudo pacman -S python
python --version
Step 3: Choose a Code Editor
- VS Code – code.visualstudio.com
- Thonny – thonny.org
- PyCharm CE – jetbrains.com/pycharm
Set Up VS Code (Recommended)
- Install VS Code
-
Install Python Extension from the VS Code Extensions tab
- Although installing the Python extension for VS Code is a simple and easy task. But, if you face any issue or need any guidelines for installing the Python Extension and configuration, visit the following links:
- Python in Visual Studio Code
- Python Extension for Visual Studio Code
- Python Setting Reference for Visual Studio Code
-
Now you are ready to create a
.py(Python) file and start coding.
Online Platforms for Running Python Code
Running Python code online provides a range of advantages that significantly enhance productivity and collaboration. One major benefit is that it eliminates the need to install or configure Python locally—users can write and execute code directly from a web browser on any device with internet access. This flexibility is especially valuable for those who work across multiple devices or need remote access to their projects.
Popular platforms that support online Python coding include:
Google Colab
Google Colab, a free, cloud-based environment provided by Google. It allows users to write and execute Python code using powerful GPUs, collaborate in real time, and store notebooks in Google Drive.
Jupyter Notebooks (Online)
Jupyter Notebooks provide an interactive, web-based interface for writing Python code, visualizing data, and combining code with formatted text.
These tools make it easier than ever to learn, share, and develop Python applications without worrying about local setup or compatibility issues.
Best Practices
- Use the latest version of Python 3
- Always add Python to your system PATH
- Practice regularly using an IDE like VS Code or Thonny
Mini Quiz
- Where do you download Python from?
- What option must you check during Windows install?
- How do you verify Python on macOS?
- Name two beginner-friendly editors.
Summary
- You installed Python successfully
- You verified the installation
- You tested Python in the terminal
- You chose a code editor for writing your code
What’s Next?
In the next lesson, you'll write and run your first Python program and understand how Python executes code step by step.