Python Forum
Error: "ModuleNotFoundError: No module named 'RPi'"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: "ModuleNotFoundError: No module named 'RPi'"
#1
Hello!

I am following this how-to: https://www.tomshardware.com/how-to/turn...spberry-pi

I am currently on the second to last step. I run the "make run" command. I received the following error

Traceback (most recent call last): File "app.py", line 2, in <module> import RPi.GPIO as GPIO ModuleNotFoundError: No module named 'RPi' make: *

I have tryed many things, and any help would be greatly appreciated! Have a good day!



In case it matters, this is on a Pi Zero 2 W running Raspberry Pi Os Buster
Reply
#2
Can you post your code?
Reply
#3
So it is a large folder full of a bunch of folders full of code. This is the code in app.py which is where it say's the error was from.

The error is:Traceback (most recent call last): File "app.py", line 2, in <module> import RPi.GPIO as GPIO ModuleNotFoundError: No module named 'RPi' make: *

Below is the code:

import RPi.GPIO as GPIO
import time
import logging
from google_assistant import GoogleAssistant


assistant = GoogleAssistant()
logging.basicConfig(level=logging.INFO)


def phone_picked_up():
    """Called when the phone is picked up"""
    logging.info('Receiver picked up')
    assistant.assist()


def phone_hung_up():
    """Called when the phone is hung up"""
    logging.info('Receiver hung up')


def listen_for_hook_state_change():
    """Continuously listens for pickup/hangup of the hook"""
    pin_number = 18
    GPIO.setmode(RPi.GPIO.BOARD)
    GPIO.setup(pin_number, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    try:
        while True:
            pin_current = GPIO.input(pin_number)
            if pin_current == 1:
                phone_picked_up()
            else:
                phone_hung_up()
            while GPIO.input(pin_number) == pin_current:
                time.sleep(0.1)
    except KeyboardInterrupt:
        print('Exiting...')
        GPIO.cleanup()


if __name__ == "__main__":
    listen_for_hook_state_change()
Larz60+ write Dec-26-2021, 01:20 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply
#4
https://pypi.org/project/RPi.GPIO/
try running pip cmd on raspberry pi
Reply
#5
Sorry, I tried that already!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 712 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 22,948 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,166 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,313 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,392 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,227 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 964 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,213 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 934 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,770 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020