Tavalin
Posts: 59
Joined: Mon Apr 16, 2012 9:53 pm

import RPi.GPIO as GPIO RuntimeError

Tue Feb 03, 2015 10:08 pm

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

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

Re: import RPi.GPIO as GPIO RuntimeError

Tue Feb 03, 2015 10:31 pm

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

Tavalin
Posts: 59
Joined: Mon Apr 16, 2012 9:53 pm

Re: import RPi.GPIO as GPIO RuntimeError

Tue Feb 03, 2015 10:51 pm

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

hayderOICO
Posts: 49
Joined: Thu May 09, 2013 3:40 pm

Re: import RPi.GPIO as GPIO RuntimeError

Wed Feb 04, 2015 10:55 am

Hi guys.,


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

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

Re: import RPi.GPIO as GPIO RuntimeError

Wed Feb 04, 2015 11:30 am

Best case for release of new RPi.GPIO by midnight tonight. It will more likely be at some point over the weekend.

hayderOICO
Posts: 49
Joined: Thu May 09, 2013 3:40 pm

Re: import RPi.GPIO as GPIO RuntimeError

Wed Feb 04, 2015 11:56 am

wohoo! that's great news!

User avatar
piborg
Posts: 11
Joined: Thu May 03, 2012 8:47 am
Contact: Website

Re: import RPi.GPIO as GPIO RuntimeError

Thu Feb 05, 2015 6:37 pm

The development version got our DiddyBorg up and running with the picamera module again.

Thanks :D
PiBorg - Control robots from your Raspberry Pi at piborg.org

Pi-Plates
Posts: 19
Joined: Sun Feb 08, 2015 12:34 pm

Re: import RPi.GPIO as GPIO RuntimeError

Sun Feb 08, 2015 12:39 pm

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?

texy
Forum Moderator
Forum Moderator
Posts: 4991
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: import RPi.GPIO as GPIO RuntimeError

Sun Feb 08, 2015 3:15 pm

Hi
It's resolved now if you are happy to use the development version.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Pi-Plates
Posts: 19
Joined: Sun Feb 08, 2015 12:34 pm

Re: import RPi.GPIO as GPIO RuntimeError

Sun Feb 08, 2015 8:20 pm

I already am - I'm looking for the final solution that my customers can apply.

Havinit
Posts: 40
Joined: Sat Feb 09, 2013 12:34 pm

Re: import RPi.GPIO as GPIO RuntimeError

Mon Feb 09, 2015 8:10 pm

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 ;)

texy
Forum Moderator
Forum Moderator
Posts: 4991
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: import RPi.GPIO as GPIO RuntimeError

Mon Feb 09, 2015 8:31 pm

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
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

gruempy
Posts: 4
Joined: Mon Feb 09, 2015 10:54 pm

Re: import RPi.GPIO as GPIO RuntimeError

Tue Feb 10, 2015 1:41 pm

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

User avatar
Bollo
Posts: 1
Joined: Thu Feb 05, 2015 5:30 pm

Re: import RPi.GPIO as GPIO RuntimeError

Tue Feb 10, 2015 6:16 pm

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
I got a bad feeling about this!

User avatar
MattRichardson
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 136
Joined: Sun Oct 07, 2012 3:39 pm
Location: San Francisco, CA
Contact: Website

Re: import RPi.GPIO as GPIO RuntimeError

Tue Feb 10, 2015 6:33 pm

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.

User avatar
DougieLawson
Posts: 29381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: import RPi.GPIO as GPIO RuntimeError

Tue Feb 10, 2015 8:26 pm

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.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

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

Re: import RPi.GPIO as GPIO RuntimeError

Tue Feb 10, 2015 11:46 pm

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.

Pi-Plates
Posts: 19
Joined: Sun Feb 08, 2015 12:34 pm

Re: import RPi.GPIO as GPIO RuntimeError

Thu Feb 12, 2015 8:01 pm

Just did an update/upgrade and saw the PiFace GPIO interface get updated.

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: import RPi.GPIO as GPIO RuntimeError

Thu Feb 12, 2015 9:25 pm

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.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

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

Re: import RPi.GPIO as GPIO RuntimeError

Fri Feb 13, 2015 12:27 am

I've fixed the bug with BOARD numbers > 26 on B+ and 2B. Currently in development version 0.5.11a1

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: import RPi.GPIO as GPIO RuntimeError

Fri Feb 13, 2015 9:43 am

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).
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

User avatar
Mettauk
Posts: 194
Joined: Mon Dec 10, 2012 12:40 pm
Location: Zarg

Re: import RPi.GPIO as GPIO RuntimeError

Fri Feb 13, 2015 12:56 pm

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!!!!
As humans we have been the same for a very very long time, technology changes how we do, not who we are as people.

hayderOICO
Posts: 49
Joined: Thu May 09, 2013 3:40 pm

Re: import RPi.GPIO as GPIO RuntimeError

Fri Feb 13, 2015 2:14 pm

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).

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

Re: import RPi.GPIO as GPIO RuntimeError

Fri Feb 13, 2015 2:47 pm

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.

User avatar
DougieLawson
Posts: 29381
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: import RPi.GPIO as GPIO RuntimeError

Fri Feb 13, 2015 5:00 pm

Well done Ben, on getting that working in less than two weeks from when the RPF surprised us with the new RPI2B.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

Return to “Python”

Who is online

Users browsing this forum: Danielya and 23 guests