'Flask error: [ModuleNotFoundError: No module named 'RPi']
I am making a simple Flask app on Raspberry pi, but I cannot include import RPi.GPIO as GPIO in python code. This is the output error:
* Serving Flask app "rgbw.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Usage: flask run [OPTIONS]
Error: While importing "rgbw", an ImportError was raised:
Traceback (most recent call last):
File "/var/www/html/rgbw/venv/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/var/www/html/rgbw/rgbw.py", line 5, in <module>
import RPi.GPIO as GPIO
ModuleNotFoundError: No module named 'RPi'
I have installed GPIO inside the virtual environment, so I don't know why it doesn't want to work.
Thanks for help!
Solution 1:[1]
Interesting... I tried pip install RPi.GPIO, and it didn't solve my problem (working ony when running the python program from Geany, but not from the terminal).
sudo apt-get -y install python3-rpi.gpio solved the issue, making it possible to run my program from the terminal.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ivo de Man |
