Skip to content

Python Environment Setup

Before you start writing Python code, the first step is to install Python on your computer. This chapter will guide you through the installation process on different operating systems.

Check Existing Version

Before installation, you can check if Python is already installed on your system. Open your terminal (Command Prompt or PowerShell on Windows) and type:

bash
python --version
# or
python3 --version

If the output shows Python 3.x.x, then you already have Python 3 installed. Make sure the version is at least 3.6. If you see "command not found" or the version is 2.x.x, please follow the steps below to install or update.

Installing on Windows

  1. Download the Installer Visit the Python official download page. Click on the latest Python 3 version download link, typically choosing "Windows installer (64-bit)".

  2. Run the Installer After downloading, double-click the .exe file to launch the installation wizard.

  3. Important Configuration On the first screen of the installation wizard, make sure to check Add Python 3.x to PATH. This adds Python's installation path to your system's environment variables, allowing you to run the python command from any directory. Then click Install Now to proceed with the default settings.

  4. Verify Installation After installation completes, open a new terminal window and type python --version. If it displays the version number, the installation was successful.

Installing on macOS

macOS usually comes with an older Python 2 version. We recommend using Homebrew, a package manager, to install the latest Python 3.

  1. Install Homebrew (if not already installed) Open Terminal and run:

    bash
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install Python using Homebrew

    bash
    brew install python3

    Homebrew will automatically handle paths and dependencies.

  3. Verify Installation After installation, type python3 --version in Terminal to verify.

Installing on Linux

Most modern Linux distributions (like Ubuntu, Fedora) come with Python 3 pre-installed. You can install or update it through the package manager.

On Ubuntu/Debian:

bash
sudo apt update
sudo apt install python3

On Fedora/CentOS:

bash
sudo dnf install python3
# or
sudo yum install python3

Package Manager: Pip

When you install Python 3, pip is usually installed automatically. pip is Python's official package manager, used to install and manage third-party libraries (such as Django, NumPy, etc.).

You can check if pip is installed successfully with:

bash
pip --version
# or
pip3 --version

Your Python development environment is now ready!

Content is for learning and research only.