Page 1 of 1

module gpiozero doesn't exist apparently

Posted: Wed Nov 18, 2015 5:04 pm
by NewbiePiUser
so i tried to run some python code in python 3(IDLE)and i get this error: Traceback (most recent call last):
File "/home/pi/gpio_button.py", line 1, in <module>
from gpiozero import LED, Button
ImportError: No module named 'gpiozero'

How do I fix that?

Re: module gpiozero doesn't exist apparently

Posted: Wed Nov 18, 2015 5:07 pm
by B.Goode

Re: module gpiozero doesn't exist apparently

Posted: Wed Nov 18, 2015 5:08 pm
by DougieLawson
You can install it with sudo pip ... or sudo pip3 ....

There may be a Raspbian package for it so some careful use of apt-cache search ... may find it.

Re: module gpiozero doesn't exist apparently

Posted: Wed Nov 18, 2015 5:09 pm
by NewbiePiUser
*FACEPALM* THANKS I THINKS ITS GONNA WORK WILL POST BACK IF IT DOESNT oops caps

Re: module gpiozero doesn't exist apparently

Posted: Sat Dec 26, 2015 9:47 pm
by con2121
i have the same problem, only i did the install adn upgrade commands, and they worked. but i still get the error. help?

Re: module gpiozero doesn't exist apparently

Posted: Sat Jan 02, 2016 4:05 pm
by ben_nuttall
Guys, I assume you're using Raspbian Wheezy - unfortunately the package is yet to be added to Wheezy but you'll find it in the Jessie repos and it comes pre-installed with the Jessie image available from the downloads page.

Update: GPIO Zero now works fine in Raspbian Wheezy.

Re: module gpiozero doesn't exist apparently

Posted: Wed Apr 27, 2016 11:18 pm
by naturesrat
Hi, i have gpiozero installed, but when I run some example code i get this import error:

ImportError: cannot import name LED

no idea why, but i'm sure its something stupid. I'm running jessie (2016-03-18)

here's the demo code (straight from the rpi site):

Code: Select all

from gpiozero import LED
from time import sleep

led = LED(17)

while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)
https://www.raspberrypi.org/blog/gpio-z ... computing/


thanks!

Re: module gpiozero doesn't exist apparently

Posted: Wed Apr 27, 2016 11:42 pm
by pxgator
The code is correct and it does work. Try using a text editor like
leafpad or nano and save the file as blink.py then from a terminal
window pointing to the directory where you saved the file type in
python blink.py (enter) and it works just fine.

Re: module gpiozero doesn't exist apparently

Posted: Thu Apr 28, 2016 4:36 am
by naturesrat
Hi, thanks, yeah i'm sure it works, and i have tried it from terminal, but i'm still getting this weird error (even from terminal) which means there must be something wrong with my gpiozero install .. I've tried to reinstall, but it says gpiozero is already installed, i've followed all of the official instructions, but if i run that exact example code, it gives me this error:

ImportError: cannot import name LED


its bizarre and i cant figure it out, has anybody else encountered this?

Re: module gpiozero doesn't exist apparently

Posted: Thu Apr 28, 2016 5:12 am
by pxgator
You might try:

Code: Select all

sudo apt-get remove python3-gpiozero python-gpiozero
Then:

Code: Select all

sudo apt-get install python3-gpiozero python-gpiozero
I'm not sure this will work but it's worth a try...??

Re: module gpiozero doesn't exist apparently

Posted: Thu Apr 28, 2016 7:09 am
by B.Goode
naturesrat wrote:Hi, thanks, yeah i'm sure it works, and i have tried it from terminal, but i'm still getting this weird error (even from terminal) which means there must be something wrong with my gpiozero install .. I've tried to reinstall, but it says gpiozero is already installed, i've followed all of the official instructions, but if i run that exact example code, it gives me this error:

ImportError: cannot import name LED


its bizarre and i cant figure it out, has anybody else encountered this?
Some suggestions:

The sample script you run must NOT be named gpiozero.py, and there must be no files named gpiozero.py or gpiozero.pyc in your current working directory.

You can check whether gpiozero is installed by doing something like this:

Code: Select all

pi@rpi2b ~ $ python3
>>> import gpiozero
>>> gpiozero
>>> exit()
You should see something similar to:

Code: Select all

pi@rpi2b ~ $ python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpiozero
>>> gpiozero
<module 'gpiozero' from '/usr/lib/python3/dist-packages/gpiozero/__init__.py'>
>>> exit()
If instead you see the location of gpiozero reported like this:

Code: Select all

<module 'gpiozero' from '/home/pi/gpiozero.py'>
it means you have ignored the first suggestion!

Re: module gpiozero doesn't exist apparently

Posted: Thu Apr 28, 2016 5:00 pm
by naturesrat
haha, yes my test file was called gpiozero.py, and then subsequent files also didnt work because that was still in the directory ...

working now, thank you!!!

(btw, seems pretty great so far!)

Re: module gpiozero doesn't exist apparently

Posted: Wed Sep 07, 2016 2:40 am
by Andy10
So ran across this thread while trying to do some simple GPIO work with my new zero. I'm getting a similar error and not sure where to go from here. I've never used the GPIO's on this particular zero before so I started with a clean install of jessie-lite (it's going to be a battery powered game box). I've tried pxgator's suggestion to uninstall and re-install and received the same error again.

I tried this:
pi@raspberrypi:~ $python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpiozero
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/gpiozero/__init__.py", line 58, in <module>
from .devices import (
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 18, in <module>
import pkg_resources
ImportError: No module named 'pkg_resources'



but not sure what it means or more importantly how to fix it.
I am running jessie release 8.0 and have tried apt-get update & upgrade.

Any suggestions are appreciated (as always).

Also, I can post this as a new question if folks prefer, but my searching led me here so I figured I'd start with this post since it had some very helpful comments already.

Thank you!

Re: module gpiozero doesn't exist apparently

Posted: Wed Sep 07, 2016 6:40 am
by B.Goode
Have you considered - if only as an experiment - starting with a Full recent version of Raspbian with the gpiozero module pre-installed.

Failing that, if you want to persist with the lite version of the OS, have you followed the installation instructions on the gpiozero documentation site: http://gpiozero.readthedocs.io/en/lates ... ml#install

If you still get a failure I would suggest reporting it directly to the developers/maintainers: http://gpiozero.readthedocs.io/en/lates ... .html#bugs

(You might have identified a shortcoming in the way the module is installed that should be brought to their attention.)

Re: module gpiozero doesn't exist apparently

Posted: Thu Sep 08, 2016 2:59 am
by Andy10
B.Goode wrote:Have you considered - if only as an experiment - starting with a Full recent version of Raspbian with the gpiozero module pre-installed.
I did try that and it works fine. Different raspberry pi zero running the full latest updated version of Jessie. I'm guessing at this point it's an issue with something that doesn't get installed on Jesse lite.
Failing that, if you want to persist with the lite version of the OS, have you followed the installation instructions on the gpiozero documentation site: http://gpiozero.readthedocs.io/en/lates ... ml#install
I did make an attempt to RTFM before posting. Going to the link you provided on the documentation however did lead me to a note I had missed the first time, so that was very helpful, thank you! Not sure if I had missed it before or what...

From the GPIOZERO Support page:
If you receive the error “No module named pkg_resources”, you need to install the pip utility. This can be done with the following command in Raspbian:

Code: Select all

$ sudo apt-get install python-pip
I tried this and updated and upgraded again and it works, sort of.

when I use python version 3 it gives me an error, but not in version 2.

Code: Select all

pi@GamePiZero:~ $ python
Python 2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpiozero
>>> gpiozero
<module 'gpiozero' from '/usr/lib/python2.7/dist-packages/gpiozero/__init__.pyc'>
>>>

Code: Select all

pi@GamePiZero:~ $ python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
i>>> import gpiozero
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gpiozero/__init__.py", line 58, in <module>
    from .devices import (
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 18, in <module>
    import pkg_resources
ImportError: No module named 'pkg_resources'
>>>

So interim solution is to use python version 2.7 for what I want to do.

If you still get a failure I would suggest reporting it directly to the developers/maintainers: http://gpiozero.readthedocs.io/en/lates ... .html#bugs

(You might have identified a shortcoming in the way the module is installed that should be brought to their attention.)
Not sure if this has risen to the level of telling the developers or not? I've never run into something that was actually an issue and not user error before...


Thank you for the response!

It got me to the point I needed to get what I want to do working.

Re: module gpiozero doesn't exist apparently

Posted: Thu Sep 08, 2016 8:18 am
by B.Goode
Andy10 wrote: when I use python version 3 it gives me an error, but not in version 2.
That can probably be fixed with:

Code: Select all

sudo apt-get install python3-pip

Re: module gpiozero doesn't exist apparently

Posted: Thu Sep 08, 2016 4:38 pm
by Andy10
B.Goode wrote:
Andy10 wrote: when I use python version 3 it gives me an error, but not in version 2.
That can probably be fixed with:

Code: Select all

sudo apt-get install python3-pip


Yep. This did it. Thank you!

Re: module gpiozero doesn't exist apparently

Posted: Sat Jun 17, 2017 10:52 pm
by Petes17
Can somebody help me, I have the same "not found" issue but I'm using Libreelec v7.0.3 MR so I can't use apt-get. I installed gpiozero from the repository "Raspberry Pi Tools". I can see the gpiozero files on this path ".kodi/addons/virtual.rpi-tools" as if it was installed but when I run my script I get this error "ImportError: No module named gpiozero".

Nevermind, I found the solution, I just had to add this code to the beginning of the script:

Code: Select all

import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')

Re: module gpiozero doesn't exist apparently

Posted: Mon Dec 25, 2017 6:28 pm
by variable_CODER1
I looked at the code that the module 'gpiozero' consists of. It has the module to import called .pins. When I look this up it doesn't exist. This is what it says:

Code: Select all

from .pins import (
    Pin,
)
from .pins.data import (
    PiBoardInfo,
    PinInfo,
    pi_info,
)
I look this up and it doesn't exist. Help?

Re: module gpiozero doesn't exist apparently

Posted: Mon Dec 25, 2017 6:42 pm
by variable_CODER1
I also get:

Code: Select all

Traceback (most recent call last):
    led = LED(4)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 122, in __call__
    self = super(GPIOMeta, cls).__call__(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 132, in __init__
    super(DigitalOutputDevice, self).__init__(pin, active_high, initial_value)
  File "/usr/lib/python3/dist-packages/gpiozero/output_devices.py", line 41, in __init__
    super(OutputDevice, self).__init__(pin)
  File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 69, in __init__
    super(SourceMixin, self).__init__(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 368, in __init__
    pin = DefaultPin(pin)
  File "/usr/lib/python3/dist-packages/gpiozero/pins/rpigpio.py", line 104, in __new__
    GPIO.setup(self._number, GPIO.IN, self.GPIO_PULL_UPS[self._pull])
RuntimeError: No access to /dev/mem.  Try running as root!
(please note: I did not include the part where it refers to files)

Re: module gpiozero doesn't exist apparently

Posted: Sun Mar 11, 2018 7:38 am
by sergiomarina
Hi.
I just installed Pyhton3.6 and I got the following output:

Code: Select all

---------------------------------------------------
1)
pi@raspberrypi:~/bin $ python pir2.py
KeyboardInterrupt
2)
pi@raspberrypi:~/bin $ python3.5 pir2.py
KeyboardInterrupt
3)
pi@raspberrypi:~/bin $ python3.6 pir2.py
Traceback (most recent call last):
  File "pir2.py", line 1, in <module>
    from gpiozero import MotionSensor
ModuleNotFoundError: No module named 'gpiozero'
---------------------------------------------------
Furthermore:
=========================
1) 
pi@raspberrypi:~/bin $ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpiozero
>>>
2) 
pi@raspberrypi:~/bin $ python3.5
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpiozero
>>>
3) 
pi@raspberrypi:~/bin $ python3.6
Python 3.6.0 (default, Mar  9 2018, 08:18:00)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpiozero
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gpiozero'
>>>
KeyboardInterrupt
============================
Is there a solution for Python version 3.6?

Thanks and brgrds, s.