Reputation: 11
I wrote a small text to control my fan that is on my raspberry pi 3 version B
.
After running the program it came up with an error:
'pi@raspberrypi:~/Development $ Sudo python3.5 run-fan.py
traceback (most recent call last):
file "run-fan.py", line 9, in <module>
import PRi.GPIO as GPIO
ImportError: No module named 'RPi'
I don't know to much about Python so I don't know what is wrong
Feel free to ask anything about the script, I thank you for your help.
Upvotes: 1
Views: 22772
Reputation: 873
For me was need to focus on using python3 with permission of sudo so rember to use sudo with python3
sudo python3 filename.py
and maybe need to active SPI by run through Terminal:
sudo raspi-config
Then
Interface Options > SPI then make sure to be activated/enabled
Upvotes: 0
Reputation: 416
Another solution is when you using GPIO on raspberry pi, you need add sudo
.
Upvotes: 1
Reputation: 71
You just need to upgrade the RPi package by the following command
sudo pip install --upgrade RPi.GPIO
If you are using python 3 the command should be like this
sudo pip3 install --upgrade RPi.GPIO
Upvotes: 2
Reputation: 1478
You have to install the module first on your Raspberry. Unfortunately I don't have one to test but according this link the command for python 3 should be (you may have to load first the package on the raspberry):
sudo apt-get -y install python3-rpi.gpio
I hope it helps,
Upvotes: 1