-
- Posts: 13
- Joined: Sat Nov 14, 2015 8:02 pm
module gpiozero doesn't exist apparently
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?
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?
What? I wuz bored!
- DougieLawson
- Posts: 40480
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: module gpiozero doesn't exist apparently
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.
There may be a Raspbian package for it so some careful use of apt-cache search ... may find it.
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
-
- Posts: 13
- Joined: Sat Nov 14, 2015 8:02 pm
Re: module gpiozero doesn't exist apparently
*FACEPALM* THANKS I THINKS ITS GONNA WORK WILL POST BACK IF IT DOESNT oops caps
What? I wuz bored!
Re: module gpiozero doesn't exist apparently
i have the same problem, only i did the install adn upgrade commands, and they worked. but i still get the error. help?
- ben_nuttall
- Posts: 235
- Joined: Sun Aug 19, 2012 11:19 am
- Location: Cambridgeshire, UK
- Contact: Website Twitter
Re: module gpiozero doesn't exist apparently
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.
Update: GPIO Zero now works fine in Raspbian Wheezy.
Former RPF staff. Author of gpiozero and creator of piwheels.
-
- Posts: 15
- Joined: Sat Feb 27, 2016 5:31 am
Re: module gpiozero doesn't exist apparently
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):
https://www.raspberrypi.org/blog/gpio-z ... computing/
thanks!
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)
thanks!
Re: module gpiozero doesn't exist apparently
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.
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.
So what's all this RPi stuff anyhow? Well folks, it's a feat of engineering from
the UK almost as remarkable as the De Havilland Mosquito and the Colossus.
the UK almost as remarkable as the De Havilland Mosquito and the Colossus.
-
- Posts: 15
- Joined: Sat Feb 27, 2016 5:31 am
Re: module gpiozero doesn't exist apparently
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?
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
You might try:
Then:
I'm not sure this will work but it's worth a try...??
Code: Select all
sudo apt-get remove python3-gpiozero python-gpiozero
Code: Select all
sudo apt-get install python3-gpiozero python-gpiozero
So what's all this RPi stuff anyhow? Well folks, it's a feat of engineering from
the UK almost as remarkable as the De Havilland Mosquito and the Colossus.
the UK almost as remarkable as the De Havilland Mosquito and the Colossus.
Re: module gpiozero doesn't exist apparently
Some suggestions: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?
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()
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()
Code: Select all
<module 'gpiozero' from '/home/pi/gpiozero.py'>
-
- Posts: 15
- Joined: Sat Feb 27, 2016 5:31 am
Re: module gpiozero doesn't exist apparently
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!)
working now, thank you!!!
(btw, seems pretty great so far!)
Re: module gpiozero doesn't exist apparently
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!
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
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.)
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
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.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 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...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
From the GPIOZERO Support page:
I tried this and updated and upgraded again and it works, sort of.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
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.
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...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.)
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
That can probably be fixed with:Andy10 wrote: when I use python version 3 it gives me an error, but not in version 2.
Code: Select all
sudo apt-get install python3-pip
Re: module gpiozero doesn't exist apparently
B.Goode wrote:That can probably be fixed with:Andy10 wrote: when I use python version 3 it gives me an error, but not in version 2.Code: Select all
sudo apt-get install python3-pip
Yep. This did it. Thank you!
Re: module gpiozero doesn't exist apparently
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:
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')
-
- Posts: 2
- Joined: Mon Dec 25, 2017 5:32 pm
Re: module gpiozero doesn't exist apparently
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:
I look this up and it doesn't exist. Help?
Code: Select all
from .pins import (
Pin,
)
from .pins.data import (
PiBoardInfo,
PinInfo,
pi_info,
)
-
- Posts: 2
- Joined: Mon Dec 25, 2017 5:32 pm
Re: module gpiozero doesn't exist apparently
I also get:
(please note: I did not include the part where it refers to files)
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!
-
- Posts: 2
- Joined: Sat Feb 24, 2018 9:34 am
Re: module gpiozero doesn't exist apparently
Hi.
I just installed Pyhton3.6 and I got the following output:
Is there a solution for Python version 3.6?
Thanks and brgrds, s.
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
============================
Thanks and brgrds, s.