Raspberry无法访问/dev/mem [英] Raspberry can't access /dev/mem
问题描述
我已在Raspberry上安装Raspbian并添加到其中:
I have installed Raspbian on my Raspberry and added in:
-
/etc/rc.local:
/etc/rc.local:
chown /dev/ttyUSB0 #to allow current user to use 3G modem
/etc/sudoers:
/etc/sudoers:
raspbian ALL=NOPASSWD: ALL
对于自动登录:
And for autologin:
1:2345:respawn:/sbin/getty --autologin raspbian --noclear 38400 tty1
在我可以使用Python中的GPIO写入GPIO引脚之前.
Before I can use GPIO from Python to write to GPIO pins.
现在,当我尝试使用sudo运行我的Python脚本时,我收到一个异常,提示我无法访问/dev/mem
Now when I try to run with sudo my Python script I receive an exception where is write that I can't access /dev/mem
我试图将"raspbian"用户添加到"kmem"组中,但不起作用.
I tried to add "raspbian" user to group "kmem" but don't works.
我尝试删除没有密码的自动登录和sudo,但也无法正常工作.
I tried to remove autologin and sudo without password, but also don't works.
我尝试使用C语言的WiringPi和WiringPi的作品.
I tried with WiringPi from C, and with WiringPi works.
请帮助我找到从python使用GPIO的解决方案.
Please help me to find a solution to use GPIO from python.
推荐答案
我发现了问题.
我忘了:
GPIO.setup(<PIN>, <MODE>)
如果没有此Python抛出异常,则写入时尝试使用root运行代码.
And without this Python throws and exception where write to try to run code with root.
这篇关于Raspberry无法访问/dev/mem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!