Python Installation and Setup

Loading

Introduction

Python is a widely used programming language known for its simplicity and versatility. This guide will walk you through the installation and setup process for Python on different operating systems.

Step 1: Download Python

  1. Visit the official Python website: https://www.python.org/downloads/
  2. The website will automatically suggest the latest version for your operating system.
  3. Click the Download Python button to get the installer.

Step 2: Install Python

Windows

  1. Run the downloaded .exe file.
  2. Check the box “Add Python to PATH” to make Python accessible from the command line.
  3. Click Install Now and wait for the installation to complete.
  4. Verify installation by opening Command Prompt and typing: python --version

macOS

  1. Open the downloaded .pkg file and follow the installation instructions.
  2. To verify the installation, open the Terminal and run: python3 --version
  3. If Python 3 is not recognized, add it to your PATH manually.

Linux (Ubuntu/Debian)

Python is usually pre-installed on Linux. To check the installed version, run:

python3 --version

If Python is not installed, use the following commands:

sudo apt update
sudo apt install python3

Step 3: Install a Code Editor (Optional)

To write and run Python scripts efficiently, install a code editor:

Step 4: Install Python Packages

Python uses pip (Python Package Installer) to install external libraries.

  • Verify pip installation: pip --version
  • Install a package, e.g., NumPy: pip install numpy

Step 5: Run a Test Script

  1. Open a text editor and create a new file named test.py.
  2. Write the following Python code: print("Hello, Python!")
  3. Save the file and run it in the terminal: python test.py

You have successfully installed and set up Python on your system! You can now start coding, install additional libraries, and explore Python’s capabilities.

Leave a Reply

Your email address will not be published. Required fields are marked *