Skip to content

Getting and Installing Python

Python is easy to install and configure on various platforms, including Windows, macOS, and Linux. Below is a step-by-step guide to download, install, and set up Python.


Step 1: Check Pre-Installed Python

  • Windows: Open Command Prompt and type:

python –version

If Python is not installed, proceed to Step 2.

  • macOS and Linux: Python often comes pre-installed. Check by typing in the terminal:

python3 –version


Step 2: Download Python

  1. Visit the Official Website:
    1. Go to Python’s official website.
  2. Choose the Version:
    1. Stable Version: Recommended for most users (e.g., Python 3.x).
    1. Older Versions: Available for compatibility with specific projects.

Step 3: Install Python

For Windows

  1. Download the Installer:
    1. Click the “Download for Windows” button on Python’s website.
  2. Run the Installer:
    1. Double-click the downloaded .exe file.
  3. Enable “Add Python to PATH”:
    1. Check the box that says “Add Python to PATH” during installation.
  4. Customize Installation (Optional):
    1. Select features like pip (Python’s package manager) and IDLE (Python’s GUI editor).
  5. Complete Installation:
    1. Follow the instructions and click “Finish.”

For macOS

  1. Download the Installer:
    1. Choose the macOS version compatible with your system (Intel or Apple Silicon).
  2. Run the Installer:
    1. Open the .pkg file and follow the instructions.
  3. Verify Installation:
    1. Open Terminal and type:

python3 –version

For Linux

  1. Use Package Manager:
    1. Most Linux distributions include Python. To install or update, use the package manager:

sudo apt update

sudo apt install python3

  • Verify Installation:
    • Check the Python version:

python3 –version


Step 4: Install pip (Python’s Package Manager)

  • Pip often comes with Python, but you can install it manually:

python -m ensurepip –upgrade


Step 5: Verify Installation

  1. Check Python Version:
    1. Open your terminal or command prompt and type:

python –version

  • Check pip Version:
    • Verify pip is installed:

pip –version


Step 6: Test Python Installation

  • Open the Python shell:

python

  • Type a simple program:

print(“Hello, World!”)

  • Exit the shell:

exit()


Step 7: Set Up Virtual Environment (Optional)

  • For project-specific package management, set up a virtual environment:

python -m venv myenv

  • Activate the virtual environment:
    • Windows:

myenv\Scripts\activate

  • macOS/Linux:

source myenv/bin/activate


Conclusion

Installing Python is straightforward, with excellent support across major operating systems. Once installed, you can use pip to manage libraries and virtual environments to organize your projects efficiently.