I have Raspberry Pi 2 Model B v1.1 (NOOBS v1.4.2 Raspbian loaded), and I installed WebIOPi 0.7.1 to use it in order to blink a LED on attached to GPIO24 and GND by WebIOPi page.

While I tried to use WebIOPi 192.168.n.n/8000 on my browser, I couldn't change the pins to blink my led. Terminal says briefly:

global name "GPIO" is not defined

But my GPIO is loaded correctly. I have already tried this code to update:

sudo apt-get install rpi.gpio

Nothing loaded and nothing changed with me. This is my Terminal's screen:

Exception happened during processing of request from ('::ffff:', 43952, 0, 0)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 655, in __init__
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
  File "build/bdist.linux-armv7l/egg/webiopi/protocols/http.py", line 267, in do_GET
  File "build/bdist.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

enter image description here enter image description here

  • 1
    I don't know WebIOPi, but the error message says that it is using Python2.7, whereas your install of RPi.GPIO seems to be for Python3.3. Python2 is NOT compatible with Python3. Perhaps that is where the issue is? – Phil B. Oct 15 '15 at 20:04
  • @PhilB You might as well write that up quick, it is probably correct. Otherwise, Bay, if it works wait the 24 hours or whatever and add your own answer. – goldilocks Oct 16 '15 at 10:40
  • @goldilocks: Done – Phil B. Oct 16 '15 at 11:44
  • I am having the same issue. Using Weaved is not really a good solution because it is a paid service. I would like to be able to do this free with the GPIO library. Am I understanding correctly that the GPIO library is not compatible with the latest RPi devices? Doesn't make sense. I have RPi 2 Model B v1.1 with the latest Raspbian image. Have been trying to get GPIO working for a while now and no joy. Tried WEBIOPi and also the regular python code. No go. I get the same exact behavior as above. – user42050 Feb 25 '16 at 16:26

From the instructions and screendumps it looks like you are using a Python3 version of RPi.GPIO, but the output of WebIOPi shows it is using Python2.7. Python2 and Python3 are NOT compatible with eachother. You will need to look for a Python2 version of RPi.GPIO such as this one. This package should have been installed by default on Raspbian, but if it didn't or if you messed it up, you can reinstall it by issuing sudo apt-get install python-rpi.gpio.

UPDATE: For Installation patches on an RPI2, please check out this WebIOPi forum thread with a link to a patch that makes WebIOPi work on B+ and 2B.

  • Sorry to say this but system detects Python 3, and tried to update it forcely update by automatically on terminal. I couldn't solved the problem so far. WebIOPi is running well on status but I can't change IN to OUT, still. Sorry, the problem is unsolved. – Bay Oct 16 '15 at 21:26
  • What do you mean with "the system"? Since they are so different, Python 2 and 3 can be installed at the same time, there would be no forced upgrade. – Phil B. Oct 16 '15 at 22:09
  • *system means Raspbian installed into Raspberry Pi 2 Model B v1.1. – Bay Oct 17 '15 at 15:53
  • May I say that I couldn't use WebIOPi with Raspberry Pi 2 Model B v1.1 ? – Bay Oct 17 '15 at 19:55
  • 2
    The patch is the solution for me: github.com/doublebind/raspi – Jianwu Chen Mar 17 '16 at 0:15

Here is the best solution for me to solve this problem. On Raspberry Pi 2 Model B v1.1's Raspbian loaded Terminal, the codes as usual for setup first:

 cd /home/pi
 sudo wget http://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz
 sudo tar xvzf WebIOPi-0.7.1.tar.gz
 cd WebIOPi-0.7.1
 sudo wget https://raw.githubusercontent.com/doublebind/raspi/master/webiopi-pi2bplus.patch
 patch -p1 -i webiopi-pi2bplus.patch
 sudo ./setup.sh

Then go on with these codes:

 cd /home/pi
 sudo wget https://github.com/weaved/installer/raw/master/binaries/weaved-nixinstaller_1.2.13.bin
 sudo chmod +x weaved-nixinstaller_1.2.13.bin
 sudo ./weaved-nixinstaller_1.2.13.bin

On the Protocol Selection Menu, type 3 then enter, then type y to continue

Now, leave terminal as working, you need to sign up on Weaved.com to go on further. [Click here to sign up][1] You need to write your new username as your mail adress and the password from Weaved.com

Then, you will see UID numbers as 80:00:00:05:46:nn:nn:nn

Then, you will see automatically named Weaved Backend Service name as an alias in order to call you with this name to recognize.

You can check the status, and to start, and to stop the service with these code:

sudo /usr/bin/Weavedwebiopi8000.sh start|status|stop

Note: Do you want to access over Internet type y then enter

Go to your new Weaved.com website page, sign in with your new ID and Password, click on my services and click on the name that we have already given it as an alias.

Finally, wait for the connection has been building up. You need to input username and password with your Webiopi ID and Password to see Webiopi status. This is your webiopi ID and password. As basic, it would be as that

name: webiopi 
password: raspberry

Then enjoy! Yiha!

Note: Starting and stopping the weaved service can be done by typing:

$ sudo /usr/bin/Weavedwebiopi8000.sh start|stop|restart

Note: My source is depending on Google Forums


For me works following this steps:

  1. Install last version webiopi if you have error or doesn't work
  2. dpkg-reconfigure webiopi //check the logs and error message
  3. sudo apt-get install rpi.gpio
  4. cd webiopi
  5. sudo wget https://raw.githubusercontent.com/doublebind/raspi/master/webiopi-pi2bplus.patch patch -p1 -i webiopi-pi2bplus.patch
  6. sudo ./setup.sh
  7. sudo /etc/init.d/webiopi start
  8. Check your browser, http://ip:8000

I had the exact same problem. Running the WebIOPi with python3 instead of python solved it immediately. (I even had the server page open in a browser and as soon as I ran the right command all the "IN" and "OUT" indicators filled themselves in next to the pins).

So instead of:

sudo python -m webiopi 8000


sudo python3 -m webiopi 8000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.