![]() |
Error: "ModuleNotFoundError: No module named 'RPi'" - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Error: "ModuleNotFoundError: No module named 'RPi'" (/thread-35835.html) |
Error: "ModuleNotFoundError: No module named 'RPi'" - LucaCodes - Dec-21-2021 Hello! I am following this how-to: https://www.tomshardware.com/how-to/turn-a-rotary-phone-into-google-assistant-with-raspberry-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 RE: Error: "ModuleNotFoundError: No module named 'RPi'" - Linenloid - Dec-24-2021 Can you post your code? RE: Error: "ModuleNotFoundError: No module named 'RPi'" - LucaCodes - Dec-25-2021 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() RE: Error: "ModuleNotFoundError: No module named 'RPi'" - Linenloid - Dec-28-2021 https://pypi.org/project/RPi.GPIO/ try running pip cmd on raspberry pi RE: Error: "ModuleNotFoundError: No module named 'RPi'" - LucaCodes - Dec-29-2021 Sorry, I tried that already! |