marius_bogdan96
Posts: 4
Joined: Wed May 29, 2019 12:04 pm

No access to dev/mem

Wed May 29, 2019 12:09 pm

Hello!
I am trying to make an automatic license plate recognition parking system with a camera andna servo. I am havingbsome troubles right at the begging with access to dev/mem. I have tried everything from old posts but nothing seems to work.
The error is for:
GPIO. setup(17, GPIO. IN, pull_up_down=GPIO. PUD_UP)
RuntimeError: No access to /dev/mem. Try running as root.
My user has acces to GPIO, i have checked.

dl324
Posts: 122
Joined: Mon May 06, 2019 7:33 pm
Location: Pacific Northwest, USA

Re: No access to dev/mem

Wed May 29, 2019 3:00 pm

As the error message indicates, root privileges are required to access /dev/mem.

User avatar
croston
Posts: 704
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: No access to dev/mem

Wed May 29, 2019 3:02 pm

* What OS / Distro are you using?
* What username is your Python program running under?
* What version of RPi.GPIO are you using?

hippy
Posts: 6775
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: No access to dev/mem

Wed May 29, 2019 4:11 pm

marius_bogdan96 wrote:
Wed May 29, 2019 12:09 pm
RuntimeError: No access to /dev/mem. Try running as root.
My user has acces to GPIO, i have checked.
Your user may have access to GPIO via /dev/gpiomem, but will need root privileges to access /dev/mem,

marius_bogdan96
Posts: 4
Joined: Wed May 29, 2019 12:04 pm

Re: No access to dev/mem

Thu May 30, 2019 6:03 am

The user is Pi. I have tried to give root access to the user byt it says it already has.
The program runed, it used to have other erros but in the process of solving them, when I finally succeded to process the image and get de number plate of the picture, it gave this error.

marius_bogdan96
Posts: 4
Joined: Wed May 29, 2019 12:04 pm

Re: No access to dev/mem

Thu May 30, 2019 6:04 am

hippy wrote:
Wed May 29, 2019 4:11 pm
marius_bogdan96 wrote:
Wed May 29, 2019 12:09 pm
RuntimeError: No access to /dev/mem. Try running as root.
My user has acces to GPIO, i have checked.
Your user may have access to GPIO via /dev/gpiomem, but will need root privileges to access /dev/mem,
How do I give root privileges?

User avatar
croston
Posts: 704
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: No access to dev/mem

Thu May 30, 2019 9:18 am

You shouldn't need root privileges with an up to date version of Raspbian and RPi.GPIO. You have still not answered my questions about the versions of things a few posts earlier. Without this information, we can only guess as to what is going wrong and what the solution is.

dl324
Posts: 122
Joined: Mon May 06, 2019 7:33 pm
Location: Pacific Northwest, USA

Re: No access to dev/mem

Thu May 30, 2019 3:19 pm

marius_bogdan96 wrote:
Thu May 30, 2019 6:04 am
How do I give root privileges?
Run the script using sudo.

hippy
Posts: 6775
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: No access to dev/mem

Thu May 30, 2019 5:29 pm

croston wrote:
Thu May 30, 2019 9:18 am
You shouldn't need root privileges with an up to date version of Raspbian and RPi.GPIO. You have still not answered my questions about the versions of things a few posts earlier. Without this information, we can only guess as to what is going wrong and what the solution is.
My guess would be it's either an ancient version of RPi.GPIO - if that is what is being used - because RPI.GPIO should be using /dev/gpiomem rather than /dev/mem to do its thing.

But RPi.GPIO falls back to using /dev/mem when it cannot gain access to /dev/gpiomem, so it could be 'lack of /dev/gpiomem' or something related which is causing the issue.

Still, running with "sudo" should allow the fall-back to using /dev/mem to work.

marius_bogdan96
Posts: 4
Joined: Wed May 29, 2019 12:04 pm

Re: No access to dev/mem

Thu May 30, 2019 9:15 pm

Thank you all. I have runed the program through MU and it works just fine, even if it still gives the gpio error in spyder 3 and geany.

Return to “Troubleshooting”