I have a python script with import RPi.GPIO as GPIO. When I execute in my Raspberry Pi3 Python3 IDLE, it runs just fine with no issues.

If I launch the script with shell pi@my_user_name, it says "no module named RPi". I am trying to add this script to be executed in my /etc/rc.local file so it can start on startup.

I have other scripts that startup just fine in Python 3 with "/usr/bin/env python3 ...myscript.py".

I have installed python 3.6 correctly many times but in the shell if I do python --version, it is 2.7.9. So I believe my shell is trying to execute in python 2 regardless if I do this: python3 /home/pi/Desktop/myscript.py

I have been going at this for hours, I also did sudo -H -u pi /user/bin/python3 /home/pi/Desktop/myscript.py in the rc.local file and it does execute, however the counts are not correct from GPIO ports when compared to python3 IDLE execute.

Is this something to do with a virtualenv of where I have python install or my RPi.GPIO? Any help is appreciated. Again the script runs perfectly when I launch through python3 IDLE.

1 Answer 1


You are barking up the wrong tree.

python IS python2 - this is in accordance with python.org standards.

If you want Python3 the correct command is python3.

There is no such file/directory as /user/bin/python3, /usr/bin/python3 is the included version /usr/bin/python3 -> python3.5

I don't know why you would install Python3.6; Debian includes Python3.5 so this would already be installed, and there is little difference - See https://docs.python.org/3/whatsnew/3.6.html

The other part of your question is unanswerable without detail of your script, BUT using /etc/rc.local is not the most reliable method. This is a hangover from SysV and systemd does its best to convert/run SysV scripts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.