Page 1 of 2

import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 03, 2015 10:08 pm
by Tavalin
Hi

Need some help with RPi2 and RPI.GPIO please.

I upgraded my openHAB box from RPi to RPi2 and as part of my setup I use a python script. However when I try and run it now I get a runtime error:

Code: Select all

Traceback (most recent call last):
  File "/opt/openhab/scripts/ENERGENIE.py", line 1, in <module>
    from energenie import switch_on, switch_off
  File "/usr/local/lib/python3.2/dist-packages/energenie/__init__.py", line 2, in <module>
    from .energenie import switch_on, switch_off
  File "/usr/local/lib/python3.2/dist-packages/energenie/energenie.py", line 1, in <module>
    import RPi.GPIO as GPIO
RuntimeError: This module can only be run on a Raspberry Pi!
What do I need to do to get this working? I had a look at /usr/local/lib/python3.2/dist-packages/energenie/energenie.py but I couldn't see anything that looks its checking we're on a RPi. Does the module need recompiling?

Thanks

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 03, 2015 10:31 pm
by croston
You need to either:
1) Wait for the next release of RPi.GPIO
2) Try the development version if you are brave. See https://sourceforge.net/p/raspberry-gpi ... i/install/

Warning: the development version may contain possible bugs with software PWM, wait_for_edge() and possibly callbacks

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 03, 2015 10:51 pm
by Tavalin
croston wrote:You need to either:
1) Wait for the next release of RPi.GPIO
2) Try the development version if you are brave. See https://sourceforge.net/p/raspberry-gpi ... i/install/

Warning: the development version may contain possible bugs with software PWM, wait_for_edge() and possibly callbacks
I'm brave, so I used the dev version from your link. Thank you very much! :D

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Wed Feb 04, 2015 10:55 am
by hayderOICO
Hi guys.,


any ETA on when the updated RPi.GPIO will be released? are we talking a few days, weeks, months?

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Wed Feb 04, 2015 11:30 am
by croston
Best case for release of new RPi.GPIO by midnight tonight. It will more likely be at some point over the weekend.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Wed Feb 04, 2015 11:56 am
by hayderOICO
wohoo! that's great news!

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Thu Feb 05, 2015 6:37 pm
by piborg
The development version got our DiddyBorg up and running with the picamera module again.

Thanks :D

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Sun Feb 08, 2015 12:39 pm
by Pi-Plates
So, I hit this last night when I was bringing up my new RPI2. At first I thought it was because I was loading the GPIO module from inside my own module but soon realized that I could make it occur by simply typing import RPi.GPIO as GPIO from the command line.

Any idea when this may be resolved?

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Sun Feb 08, 2015 3:15 pm
by texy
Hi
It's resolved now if you are happy to use the development version.
Texy

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Sun Feb 08, 2015 8:20 pm
by Pi-Plates
I already am - I'm looking for the final solution that my customers can apply.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Mon Feb 09, 2015 8:10 pm
by Havinit
Just got bitten by this. It is a little bit disappointing that a release version wasn't ready for the hardware rollout, given this is a fairly crucial package for the educational and maker markets (and as I imagine all that's missing is some board identifier that RPF or RS could probably have known and relayed to them well in advance).

That said, part of what I love about the whole Pi experience is that they never do things the way big box-shifters with MBAs and marketing gurus do; so I'll take a little of the rough with the smooth ;)

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Mon Feb 09, 2015 8:31 pm
by texy
Maybe, but bear in mind that these packages are not authored or maintained by the foundation, but purely by volunteers. I suspect that Croston neither had a Pi 2 or prior knowledge of its release before the general public did. This is what happens when you have leading edge hardware - I suspect that this will be resolved by the time the educational bodies use the Pi 2 in earnest, and in any case the hackers and makers already have a workaround.
Texy

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 10, 2015 1:41 pm
by gruempy
Hi

I have just got a new RPi2 and was trying to get the GPIO working under Python but got the same error in the original report i.e. module only runs on a Raspberry Pi, I had previously run the apt-get update and upgrade and appear to be running the 0.5.9 code
pi@jarp ~ $ find /usr | grep -i gpio
/usr/share/pyshared/RPi.GPIO-0.5.9.egg-info
/usr/share/doc/python3-rpi.gpio
/usr/share/doc/python3-rpi.gpio/changelog.gz
/usr/share/doc/python3-rpi.gpio/copyright
/usr/share/doc/python3-rpi.gpio/changelog.Debian.gz
/usr/share/doc/python-rpi.gpio
/usr/share/doc/python-rpi.gpio/changelog.gz
/usr/share/doc/python-rpi.gpio/copyright
/usr/share/doc/python-rpi.gpio/changelog.Debian.gz
/usr/lib/python3/dist-packages/RPi.GPIO-0.5.9.egg-info
/usr/lib/python3/dist-packages/RPi/GPIO.cpython-32mu.so
/usr/lib/python2.7/dist-packages/RPi.GPIO-0.5.9.egg-info
/usr/lib/python2.7/dist-packages/RPi/GPIO.so
/usr/lib/pyshared/python2.7/RPi/GPIO.so
/usr/lib/pyshared/python2.6/RPi/GPIO.so
/usr/lib/python2.6/dist-packages/RPi.GPIO-0.5.9.egg-info
/usr/lib/python2.6/dist-packages/RPi/GPIO.so

But I noticed that the hardware displayed when running
cat /proc/cpuinfo
is BMC2709 - is this causing the problem with the system not recognising it is running on a Raspberry Pi ? Is there likely to be a fix or do I have to try the dev code with attendant risks.

pi@jarp ~ $ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 1
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 2
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

processor : 3
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5

Hardware : BCM2709
Revision : a01041
Serial : 0000000078484eb9

I am a school governor trying out some programs for the school and would prefer not to have to ask the school to use dev code rather than mainline code, if possible.

Many thanks

John

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 10, 2015 6:16 pm
by Bollo
Hi,
I'm new to the Raspberry Pi and just purchased the Pi2. I've been watching this post for a few days and like the rest of you waiting for an upgrade to Rpi.GPIO 5.0.9

I thought I might take a punt on the 'dev version' fix but when I tried the link to Sourceforge.net provided by Tavalin above I got an 'Untrusted Connection' warning from Firefox.

Just a couple of Questions:
1: Is the fix imminent? When I first logged on last Friday there was a hope there would be a permanent fix by Monday.

2: If not, please could someone provide brief instructions / directions on where to download the 'dev version' from a secure connection.

Thanks

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 10, 2015 6:33 pm
by MattRichardson
Bollo wrote:I thought I might take a punt on the 'dev version' fix but when I tried the link to Sourceforge.net provided by Tavalin above I got an 'Untrusted Connection' warning from Firefox.
Yeah, it appears Sourceforge is down right now. Here's what I'm seeing:
The sourceforge.net website is temporarily in static offline mode.
Only a very limited set of project pages are available until the main website returns to service.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 10, 2015 8:26 pm
by DougieLawson
It's not quite down, it's exceedingly intermittent. After about fifteen goes I got the RPi.GPIO release candidate code installed for both python2 & python3.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Tue Feb 10, 2015 11:46 pm
by croston
The latest RPi.GPIO will be available in Raspbian when the new firmware it depends on is also in Raspbian.

I don't want to break kids toys with buggy PWM that occurs without the firmware fix. I have yet to write the code that disables PWM on a Pi2 with old firmware.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Thu Feb 12, 2015 8:01 pm
by Pi-Plates
Just did an update/upgrade and saw the PiFace GPIO interface get updated.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Thu Feb 12, 2015 9:25 pm
by meltwater
croston wrote:The latest RPi.GPIO will be available in Raspbian when the new firmware it depends on is also in Raspbian.

I don't want to break kids toys with buggy PWM that occurs without the firmware fix. I have yet to write the code that disables PWM on a Pi2 with old firmware.
Hi,
Just installed RPi.GPIO 0.5.10-1 just tried accessing the GPIO pins above 26 (37,35,33), using GPIO.setmode(GPIO.BOARD) and it says it isn't valid. Appears to work using GPIO.BCM and the relevant GPIO numbering (i.e. GPIO26, GPIO19, GPIO13). Is there a problem with the board rev detection and pin limits on RPi2?

Many thanks.
Tim.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Fri Feb 13, 2015 12:27 am
by croston
I've fixed the bug with BOARD numbers > 26 on B+ and 2B. Currently in development version 0.5.11a1

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Fri Feb 13, 2015 9:43 am
by meltwater
croston wrote:I've fixed the bug with BOARD numbers > 26 on B+ and 2B. Currently in development version 0.5.11a1
Awesome!
Thanks for your time in putting the fixes in (and to all the other developers/community members which have been hit by the hardware changes). There is more impacted than I had originally realised.

----------------
In general:

I know it is only temporary, but a general list on release of known "problems"** would have been very helpful (and would probably unite the community in resolving/explaining to the userbase).

**They are not even problems, if you are aware of them...but is a huge roadblock for users (particularly beginners) if they start to try something and have it not work without any explanation. I hate to think that excited new users are running into issues and are simply giving up on it - many I fear will end up putting it in a draw and that will be that, spark gone... Of course the hardcore will press-on regardless, but people have to start somewhere.

Perhaps an overall troubleshooting page for A+/B+ and RPi2 is needed...which will help users adjust to the changes (and provide a referencing point for content creators).

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Fri Feb 13, 2015 12:56 pm
by Mettauk
meltwater wrote: ----------------
In general:

I know it is only temporary, but a general list on release of known "problems"** would have been very helpful (and would probably unite the community in resolving/explaining to the userbase).

**They are not even problems, if you are aware of them...but is a huge roadblock for users (particularly beginners) if they start to try something and have it not work without any explanation. I hate to think that excited new users are running into issues and are simply giving up on it - many I fear will end up putting it in a draw and that will be that, spark gone... Of course the hardcore will press-on regardless, but people have to start somewhere.

Perhaps an overall troubleshooting page for A+/B+ and RPi2 is needed...which will help users adjust to the changes (and provide a referencing point for content creators).
Here, Here!!!!

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Fri Feb 13, 2015 2:14 pm
by hayderOICO
awaiting the 0.5.11!

yes, I am also using the GPIO pins 26-40... and I'd rather not change over to BCM (since that's variable between models).

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Fri Feb 13, 2015 2:47 pm
by croston
I'm aiming to do the release tonight if possible. I'll probably add GPIO.getmode(), GPIO.board_num() and GPIO.bcm_num() at the same time. This should help when RPi.GPIO is used by other third party libraries that choose the 'other' numbering system to the one that you want.

Re: import RPi.GPIO as GPIO RuntimeError

Posted: Fri Feb 13, 2015 5:00 pm
by DougieLawson
Well done Ben, on getting that working in less than two weeks from when the RPF surprised us with the new RPI2B.