Open links in new tab
  1. To use Python modules on a Raspberry Pi, you need to ensure they are installed and properly imported into your Python scripts. Below are the steps to install and import Python modules effectively.

    Installing Modules Using pip

    • Open Terminal: Launch the terminal on your Raspberry Pi.

    • Install the Module: Use the following command to install a module:

    sudo pip3 install <module_name>
    Copied!
    • Verify Installation: Check if the module is installed:

    pip3 list
    Copied!
    • Upgrade or Uninstall Modules: Upgrade: sudo pip3 install --upgrade <module_name> Uninstall: sudo pip3 uninstall <module_name>

    Using APT for Common Libraries

    For some libraries available in Raspberry Pi OS repositories, you can use apt:

    • Search for the library:

    apt search python3-<library_name>
    Copied!
    • Install it:

    sudo apt install python3-<library_name>
    Copied!

    Importing Modules in Python Scripts

    Once installed, you can import the module in your Python script:

    import <module_name>
    Copied!

    Example:

    import requests

    response = requests.get('https://api.github.com')
    print(response.status_code)
    Copied!
  1. Installing Python modules with pip - Raspberry Pi

    Modules can be downloaded as packages from the Python Package Index and installed on your computer automatically. To install a module, use the pip3 install name_of_mo
    Raspberry Pi

    1. Open a terminal window by clicking Menu > Accessories > Terminal.
    2. Enter this command to install a module:

    Windows

    Open a command prompt by clicking Start > Windows System > Command Prompt, or by typing ‘command’ into the start menu’s search bar.

    Macos

    1. Open a terminal window by clicking Applications > Utilities > Terminal, or by typing ‘terminal’ into the desktop’s search …
    2. Enter this command to install a module:

    Linux

    1. Open a terminal window.
    2. Enter this command to install a module:

  2. How to Install and Use Python Packages on Raspberry Pi?

    • See More

    Jun 11, 2025 · Even if you are good with Python, you might need some help knowing how to install new packages for Python on Raspberry Pi, which is exactly why I wrote this article.

  3. How To Install Python Modules on Raspberry Pi 5 and …

    Oct 21, 2023 · You will almost certainly need to install Python modules to program any HATs, including the best Raspberry Pi HATs, so this matters a lot.

  4. How to Comprehensively Install Python Packages on Your Raspberry …

    Dec 27, 2023 · But first, you need to know how to install packages on your Raspberry Pi. In this 2500+ word guide, you‘ll get a comprehensive overview of Python packages—what they are, why they matter, …

  5. Using Python with virtual environments | The MagPi …

    Nov 21, 2024 · This handy tutorial will get you started on Python, which comes pre-installed on Raspberry Pi OS.

  6. Install Python Package on Raspberry Pi - PyTutorial

    May 28, 2025 · Installing Python packages on a Raspberry Pi is simple. This guide covers different methods. You will learn to use pip, apt, and virtual environments.

  7. Modules in Python for Raspberry Pi - mechatronicslab.net

    In this guide, we’ve covered the basics of modules in Python for Raspberry Pi, including how to import built-in modules, create your own, and install third-party modules with pip.

  8. Installing Python Packages on Raspberry Pi - halvorsen.blog

    • A Python Virtual Environment is an isolated space where you can work on your Python projects, separately from your system- installed Python. • You can set up your own libraries and dependencies …

  9. Python Libraries Every Developer Needs to Know for …

    Python is an easy-to-use programming language that works natively on the …

    • Reviews: 31.4K
    • How to Install Python Packages in Raspberry Pi OS …

      Dec 30, 2023 · The "Bookworm" version of Raspberry Pi OS, as used on Raspberry Pi 5, brings some changes to the way Python modules are installed.