When I write a program in Python using IDLE3, I can run it from the IDLE3 Python shell. But when I add GPIO.setup(7, GPIO.out) to my code I get an error message 'No access to DEV/MEM Try running as root.
To make it run, I have to go to the terminal and type SUDO python filename.py then it works.
The identical code on my friend's Raspberry Pi runs perfectly from within the IDLE3 Python shell. I have spent hours trying to get to the bottom of this problem and got nowhere, please can someone help me?
Re: No access to DEV/MEM
The actual message you saw should have been dev/mem and the command you used should have been sudo. It doesn't matter here but it can help us to help you if you give accurate error messages.
I guess your friend is running as root, perhaps by using the command sudo idle3
I guess your friend is running as root, perhaps by using the command sudo idle3
Re: No access to DEV/MEM
In order to access GPIO's you must run as root as Linux will not let you play around with the hardware without the right privileges. So you are right that you need sudo, but i suspect your friend is also running as root somehow (see previous post)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.
Re: No access to DEV/MEM
Thank you for such a prompt and correct answer, and I will try and be more precise with error messages etc. in the future.
Yes, my friend was indeed invoking IDLE3 by typing sudo IDLE3 at the terminal, whilst I was invoking it from the GUI desktop.
So this (my first!) post is now closed - thanks again
Yes, my friend was indeed invoking IDLE3 by typing sudo IDLE3 at the terminal, whilst I was invoking it from the GUI desktop.
So this (my first!) post is now closed - thanks again
Re: No access to DEV/MEM
I'm new to RPI 2 and have simmelar question.
I've setup my RPI with VCN as described in my living room and was able to open, edit and run existing ,py scripts from my desktop using VCN.
Then I moved the RPI to the basement where the sensors are and created my first scrip. Everything's fine till I hit the first GPIO command and get the "No access to /dev/mem" error.
When trying the "sudo idle3" in the LXTerminal, I get the error blow.
Where did I go wrong?
I've setup my RPI with VCN as described in my living room and was able to open, edit and run existing ,py scripts from my desktop using VCN.
Then I moved the RPI to the basement where the sensors are and created my first scrip. Everything's fine till I hit the first GPIO command and get the "No access to /dev/mem" error.
When trying the "sudo idle3" in the LXTerminal, I get the error blow.
Where did I go wrong?
- Attachments
-
- rpiVNC1.jpg (26.93 KiB) Viewed 2374 times
- DougieLawson
- Posts: 40553
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: No access to DEV/MEM
Try running idle with gksudo idle.
Or rewrite your python program to use GPIOzero (which doesn't need sudo or gksudo).
Or rewrite your python program to use GPIOzero (which doesn't need sudo or gksudo).
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: No access to DEV/MEM
DougieLawson wrote:Try running idle with gksudo idle.


Re: No access to DEV/MEM
Tried to install gpiozero with both sudo and gksudo without sucsess. see belowOr rewrite your python program to use GPIOzero (which doesn't need sudo or gksudo).
(spidev had the same issue)
Or is there another way to rewrite python? (trough VNC)
- Attachments
-
- arvix4.jpg (61.69 KiB) Viewed 2200 times
- DougieLawson
- Posts: 40553
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: No access to DEV/MEM
What OS are you running Jessie or Wheezy?
Have you run sudo apt-get update && sudo apt-get upgrade recently? If not do that and try again with sudo apt-get install python-gpiozero python3-gpiozero
Have you run sudo apt-get update && sudo apt-get upgrade recently? If not do that and try again with sudo apt-get install python-gpiozero python3-gpiozero
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
- ben_nuttall
- Posts: 235
- Joined: Sun Aug 19, 2012 11:19 am
- Location: Cambridgeshire, UK
- Contact: Website Twitter
Re: No access to DEV/MEM
The new Jessie image contains the fix to make GPIO work without sudo, and also comes with GPIO Zero pre-installed.
Grab it from the downloads page
Grab it from the downloads page
Former RPF staff. Author of gpiozero and creator of piwheels.