Installation guides

Installing Python on Debian

Step-by-Step Guide

  1. Update the Package Index
    Open a terminal and update the package index to ensure you have the latest information about available packages:
   sudo apt update
  1. Install Python
    Debian typically comes with Python pre-installed. However, you can install the latest versions of Python using the apt package manager:
   sudo apt install python3 python3-pip

This command installs Python 3 and pip, the Python package installer.

  1. Verify Python Installation
    Check the Python version to ensure it is installed correctly:
   python3 --version

You should see the Python version information displayed.

  1. Verify pip Installation
    Check the pip version to ensure it is installed correctly:
   pip3 --version

You should see the pip version information displayed.

  1. Install Virtualenv (Optional)
    It’s a good practice to use virtual environments for your Python projects. Install virtualenv using pip:
   sudo pip3 install virtualenv
  1. Create a Virtual Environment (Optional)
    Create a new virtual environment for your project:
   virtualenv venv

Activate the virtual environment:

   source venv/bin/activate

Your command prompt should change to indicate that the virtual environment is active.

  1. Install Packages with pip
    You can now install Python packages within your virtual environment using pip. For example, to install Flask, a popular web framework, use:
   pip install flask
  1. Deactivate the Virtual Environment
    When you are done working in the virtual environment, deactivate it:
   deactivate
  1. Create a Simple Python Script
    To test your Python installation, create a simple Python script:
   nano hello.py

Add the following code to the file:

   print("Hello, World!")

Save and close the file.

  1. Run the Python Script
    Execute the script to ensure Python is working correctly:
    bash python3 hello.py
Other Recent Posts