Hunter275 / webiopi

Automatically exported from code.google.com/p/webiopi
0 stars 0 forks source link

AttributeError: ‘module’ object has no attribute ‘GPIO’ #97

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1- download release 0.7.9 source code
2- perform install through : sudo ./setup.sh
3- run old project that was using version 0.6.2

The upgrade / installation finished successfully .. when I tried to run the 
project I was working on I got this weird error:

WebIOPi version used?
=> 0.7.0

Python version used?
=> 2.7.6

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

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

For Javascript side bugs, Browser?
=> No

Please provide any additional information below.

when running the server: sudo webiopi -c /etc/webiopi/config -d

Traceback (most recent call last):
File “build/bdist.linux-armv6l/egg/webiopi/__main__.py”, line 75, in
main(sys.argv)
File “build/bdist.linux-armv6l/egg/webiopi/__main__.py”, line 69, in main
server = Server(port=port, configfile=configfile, scriptfile=scriptfile)
File “build/bdist.linux-armv6l/egg/webiopi/server/__init__.py”, line 75, in 
__init__
loader.loadScript(name, source, self.restHandler)
File “build/bdist.linux-armv6l/egg/webiopi/utils/loader.py”, line 8, in 
loadScript
script = imp.load_source(name, source)
File “/home/pi/webio/python/script.py”, line 7, in
GPIO = webiopi.GPIO
AttributeError: ‘module’ object has no attribute ‘GPIO’

Original issue reported on code.google.com by isale...@gmail.com on 18 Apr 2014 at 8:54

GoogleCodeExporter commented 9 years ago
Module structure has slightly been reorganized from 0.6.2 to 0.7.0 release. For 
that, 0.6.2 custom Python server scripts don't run eventuelly properly due to 
module import errors. Please look at the 0.7.0 server script examples and adapt 
your script (nainly imports) to the changed module structures and then it will 
run again.

Original comment by andreas....@googlemail.com on 23 Apr 2014 at 7:46

GoogleCodeExporter commented 9 years ago
Actually .. I used the exact server script on the site (0.7.0) .. 

Original comment by isale...@gmail.com on 26 Apr 2014 at 11:05

GoogleCodeExporter commented 9 years ago
Are you sure that the compiling of the native C interface module of WebIOPi for 
the native GPIO ports really succeeded? It looks like that is missing for some 
reason.
Maybe your Distro is missing the gcc or something else went wrong.

Re-run the setup script and watch out for errors when compiling the native C 
code parts.

Original comment by andreas....@googlemail.com on 30 Apr 2014 at 1:29

GoogleCodeExporter commented 9 years ago
I had this issue and found a fix after hours of installing/unistalling webiopi

cd 
/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv61.egg/_web
iopi/

In this directory I was missing the file __init__.py
if you are missing it too, create it in nano and add the line:
__import__("pkg_resources").declare_namespace(__name__)

save and exit and try running your webiopi again.

Original comment by harrybro...@gmail.com on 2 May 2014 at 1:26

GoogleCodeExporter commented 9 years ago
note the double underscores, kinda looks like just one to me but they are 
doubles 

Original comment by harrybro...@gmail.com on 2 May 2014 at 1:28

GoogleCodeExporter commented 9 years ago
I'm still getting this issue, is there any workaround to solve it? I have 
checked the specified path by Harry and I have the file right in place with the 
corresponding code but still when trying to import it into my custom python 
script I'm getting that error.

Original comment by Alex.Szi...@gmail.com on 9 Jun 2014 at 11:19

GoogleCodeExporter commented 9 years ago
In the end managed to solve it by reinstall the OS and Webiopi :)

Original comment by Alex.Szi...@gmail.com on 10 Jun 2014 at 3:03

GoogleCodeExporter commented 9 years ago
I'm experiencing this as well, not sure what is going wrong. Is it possible to 
force webiopi to use specific python version?

Original comment by Christof...@gmail.com on 13 Nov 2014 at 10:30

GoogleCodeExporter commented 9 years ago
I'm having the same error (see issue #130).

Original comment by istva...@gmail.com on 13 Dec 2014 at 5:27

GoogleCodeExporter commented 9 years ago
I have the same problem anyone know how to fix it

Original comment by alveo...@gmail.com on 6 Jan 2015 at 7:41

GoogleCodeExporter commented 9 years ago
raspberry pi2 same error !!

Original comment by giancap...@gmail.com on 9 Mar 2015 at 9:43

GoogleCodeExporter commented 9 years ago
i had the same error for WebIOPi-0.7.1. this error raised because WebIOPi-0.7.1 
need python3
just add --> #!/usr/bin/python3 <-- at your python script. 

this my test1.py script :

#!/usr/bin/env python3

import webiopi
import time

GPIO = webiopi.GPIO

LIGHT = 17

GPIO.setFunction(LIGHT, GPIO.OUT)

GPIO.digitalWrite(LIGHT, GPIO.HIGH)
time.sleep(1)
GPIO.digitalWrite(LIGHT, GPIO.LOW)

run with --> #python test1.py and python3 test1.py 
see the different

Original comment by hixo...@gmail.com on 6 Apr 2015 at 12:55

GoogleCodeExporter commented 9 years ago
sorry adding the python3 as described, does not work
/python $ python3  script.py 
Traceback (most recent call last):
  File "script.py", line 6, in <module>
    GPIO = webiopi.GPIO
AttributeError: 'module' object has no attribute 'GPIO'

Original comment by Peter.Di...@rocflevoland-ict.nl on 11 Apr 2015 at 8:17

GoogleCodeExporter commented 9 years ago
Anyone got rid of this issue?? Still getting same error :(

Original comment by a...@sparsa.com on 13 Apr 2015 at 1:39

GoogleCodeExporter commented 9 years ago
I tried the test script and i got no error in the first try.

pi@raspberrypi ~/myproject/python $ sudo python test1.py 
pi@raspberrypi ~/myproject/python $ sudo python3 test1.py 
Traceback (most recent call last):
  File "test1.py", line 6, in <module>
    GPIO = webiopi.GPIO
AttributeError: 'module' object has no attribute 'GPIO'
pi@raspberrypi ~/myproject/python $ 

Original comment by cbobadil...@gmail.com on 17 Apr 2015 at 7:19

GoogleCodeExporter commented 9 years ago
The sudo added to the command does not make a difference with my installation. 
I have a fresh image ( updated, upgraded), with only the webiopi installed, the 
gertboard software does work with python. 

where does the webiopi.GPIO come from ? where defined, is there a debug to see 
which of the libraries are included (I am not that familiar with python)

Original comment by Peter.Di...@rocflevoland-ict.nl on 19 Apr 2015 at 10:08

GoogleCodeExporter commented 9 years ago
I have the same problem with a RaPi 2 and a new installed Wheezy image and 
WebIoPi. When I start my Python program manually I have no prolbem. I have the 
problem only if I start the program at start-up via upstart.

Maybe it is a right issue?

Because when I start my python programm manually then I alway start it via sudo 
python...

Original comment by ingmar.s...@googlemail.com on 19 Apr 2015 at 10:31

GoogleCodeExporter commented 9 years ago
I have the same error and I'm going crazy to find the solution. I changed all 
versions of python, webiopi and the problem continues. Please report if you 
find solution or this forum.
thank you very much

Original comment by marko...@gmail.com on 21 Apr 2015 at 5:36

GoogleCodeExporter commented 9 years ago
AttributeError: 'module' object has no attribute 'GPIO'

webiopi on raspberry pi2
this worked for me in stopping the above error...found this fix by luck!

in the webiopi-0.7.1 directory is the python directory, continue below:
1.python/native/cpuinfo.c,change "BCM2708" to "BCM2709";
2.python/native/gpio.c, change "#define BCM2708_PERI_BASE 0x20000000" to 
"#define BCM2708_PERI_BASE 0x3f000000";
3.run setup.sh again.

i hope this helps

Original comment by reidcla...@gmail.com on 23 Apr 2015 at 1:08

GoogleCodeExporter commented 9 years ago
#19 worked for me...thank you 

Original comment by mark.ost...@gmail.com on 24 Apr 2015 at 5:13

GoogleCodeExporter commented 9 years ago
worked for me too, GREAT
I did see same changes in de gert-board software but did not know where in the 
python software to change

there is also an issue with the GPIO numbering, please check Pi documentation. 
You'll come accros that too.

this is fixed, thanks

Original comment by Peter.Di...@rocflevoland-ict.nl on 24 Apr 2015 at 6:29