Issue #134 [New/open] - ERROR - global name 'GPIO' is not defined

Posted by junquan.zhou

What steps will reproduce the problem? 1.install webiopi 2.add two line on /etc/webiopi/config [GPIO] 7 = OUT 1 8 = OUT 1 3.sudo webiopi -d -c /etc/webiopi/config ...

WebIOPi version used? =>0.7.0

Python version used? =>3.2

Distro used? (WebIOPi has only been tested on Raspbian Wheezy) =>Raspbian

Raspberry Pi board revision? (1 or 2) =>2

For Javascript side bugs, Browser? =>no

Please provide any additional information below.

pi@pi2garage ~ $ sudo webiopi -d -c /etc/webiopi/config 2015-02-06 22:35:40 - WebIOPi - INFO - Starting WebIOPi/0.7.0/Python3.2 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.digitalCount to REST GET /GPIO/count 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.digitalRead to REST GET /GPIO/%(channel)d/value 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.digitalWrite to REST POST /GPIO/%(channel)d/value/%(value)d 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.getFunctionString to REST GET /GPIO/%(channel)d/function 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.getPulse to REST GET /GPIO/%(channel)d/pulse 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.outputSequence to REST POST /GPIO/%(channel)d/sequence/%(args)s 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.portRead to REST GET /GPIO/*/integer 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.portWrite to REST POST /GPIO/*/integer/%(value)d 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.pulse to REST POST /GPIO/%(channel)d/pulse/ 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.pulseAngle to REST POST /GPIO/%(channel)d/pulseAngle/%(value)f 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.pulseRatio to REST POST /GPIO/%(channel)d/pulseRatio/%(value)f 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.setFunctionString to REST POST /GPIO/%(channel)d/function/%(value)s 2015-02-06 22:35:40 - WebIOPi - DEBUG - Mapping GPIO.wildcard to REST GET /GPIO/* 2015-02-06 22:35:40 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO 2015-02-06 22:35:40 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config 2015-02-06 22:35:40 - WebIOPi - ERROR - global name 'GPIO' is not defined Traceback (most recent call last): File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/__main__.py", line 75, in <module> main(sys.argv) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/__main__.py", line 69, in main server = Server(port=port, configfile=configfile, scriptfile=scriptfile) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/server/__init__.py", line 52, in __init__ self.gpio.addSetups(config.items("GPIO")) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 62, in addSetups self.addGPIOSetup(gpio, params) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 55, in addGPIOSetup self.addGPIO(self.gpio_setup, gpio, params) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv7l.egg/webiopi/devices/digital/gpio.py", line 45, in addGPIO func = GPIO.OUT NameError: global name 'GPIO' is not defined


Comment 1

Posted by andreas.riegg

If GPIO is undefined your initial setup may have been incomplete, i.e. the compilation of the native C module for GPIO may have failed.

Redo setup and check if everything went through correct.


Comment 2

Posted by lukaszbek

I have same issue, redo setup multiple times and it does not work. Raspberry PI 2 is fresh Raspian installed and second thing done is install WebIOPi.


Comment 3

Posted by junquan.zhou

I believe it's the GPIO library not compatible with Pi2 yet. Hopefully they will release new update soon. Finger cross!


Comment 4

Posted by tallguy999

Hi, complete Rpi newby here, but getting the exact same error - all routes seem to lead to an incompatibility with the new Pi?


Comment 6

Posted by tallguy999

To add, I updated to RPi.GPIO 0.5.10 and still get the same issue. The error materializes in the verbose logging when I click any of the buttons / pins on the GPIO-Header page.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.2/socketserver.py", line 295, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib/python3.2/socketserver.py", line 321, in process_request self.finish_request(request, client_address) File "/usr/lib/python3.2/socketserver.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python3.2/socketserver.py", line 648, in __init__ self.handle() File "/usr/lib/python3.2/http/server.py", line 396, in handle self.handle_one_request() File "/usr/lib/python3.2/http/server.py", line 384, in handle_one_request method() File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/http.py", line 267, in do_GET self.processRequest() File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.1-py3.2-linux-armv7l.egg/webiopi/protocols/http.py", line 258, in processRequest except (GPIO.InvalidDirectionException, GPIO.InvalidChannelException, GPIO.SetupException) as e: NameError: global name 'GPIO' is not defined


Comment 7

Posted by emymar

I got same error on Pi2. Please help!


Comment 8

Posted by Nils.Heilemann

Here is the fix: https://www.techboard-online.de/thread-32-post-76.html#pid76

The unfixed Version of WebIOPi doesn't support the Raspberry Model 2.