-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gpiozero does not work on Linux Kernel 6.6.20 #1131
Comments
Can you paste your full code please? |
Ahhh, it looks like this might be related to https://sourceforge.net/p/raspberry-gpio-python/tickets/210/ Can you please do |
See also raspberrypi/linux#6037 for more details of why RPi.GPIO no longer works with the 6.6 Linux kernel. |
Now fails with two lgpio errors: Test code with full stack trace:
During handling of the above exception, another exception occurred: Traceback (most recent call last): Pip versions: certifi 2024.2.2 Also: |
Can you try using the system-installed python3, instead of using a venv? See further discussion in #1038 |
So I think this was due to the very old version of lgpio (0.0.0.2) that is in the pip library. I downloaded the latest version (0.2.2.0) from https://github.com/Gadgetoid/PY_LGPIO and installed it and it works fine. |
But I do get a GPIO busy error when it first starts up but the program stll runs and I/O pins work OK (input and output): |
That means an other program is running and using it, close/kill other Python/Thonny etc. |
I kinda gathered that 😄. Get it after a clean reboot - the python starts up as a service and it gets the same exception thrown. Appears to be when the library starts it's threadpool but doesn't impact any I/O operation or event detection. No other services or program is using GPIO, so a bit of a mystery. |
So whats the workaround? I switched from
I guess the native pin factory does not work either? |
This is not related to Kernel 6.6.x
Rhis is your virtual environment and the lack of a pypi lgpio module.
You need to open you venv to system modules, there is currently no other
easy way.
See the last part of my chat here.
#1132
…On Sun, 24 Mar 2024, 10:53 pm Matyas Forian-Szabo, ***@***.***> wrote:
So whats the workaround? I switched from RPI.GPIO to this library hoping
my code would work, but it does not. My log:
/home/aaa/CODE/pi-radio/venv/lib/python3.11/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from lgpio: No module named 'lgpio'
warnings.warn(
/home/aaa/CODE/pi-radio/venv/lib/python3.11/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi'
warnings.warn(
/home/aaa/CODE/pi-radio/venv/lib/python3.11/site-packages/gpiozero/devices.py:300: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio'
warnings.warn(
/home/aaa/CODE/pi-radio/venv/lib/python3.11/site-packages/gpiozero/devices.py:297: NativePinFactoryFallback: Falling back to the experimental pin factory NativeFactory because no other pin factory could be loaded. For best results, install RPi.GPIO or pigpio. See https://gpiozero.readthedocs.io/en/stable/api_pins.html for more information.
warnings.warn(NativePinFactoryFallback(native_fallback_message))
Traceback (most recent call last):
File "/home/aaa/CODE/pi-radio/venv/lib/python3.11/site-packages/gpiozero/pins/native.py", line 237, in export
result = self._exports[pin]
~~~~~~~~~~~~~^^^^^
KeyError: 20
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/aaa/CODE/pi-radio/venv/lib/python3.11/site-packages/gpiozero/pins/native.py", line 247, in export
result = os.open(self.path_value(pin),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/sys/class/gpio/gpio20/value'
I guess when the native pin factory does not work either?
—
Reply to this email directly, view it on GitHub
<#1131 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACYAXN6LBIJSQ4I3DW2BVW3YZ5KODAVCNFSM6AAAAABFBBJVYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWHE3TKMRVHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
hm I dont understand, the error says that I have the But I guess, I'll abandon using this library, I just need manual GPIO control, and this seems like a classroom project hardcoded with tons of stuff I dont need. Anyone knows the most performant GPIO library that actually works with the latest Pi update? Whats out:
tbh I dont understand why the pi foundation thought it would be OK to break the few easy to use libraries overnight without warning. |
If you are using RaspberryPi OS "bookworm" then it is lgpio you will need
to use, that meas gpiozero will also work.
BUT you are asking under a kernel 6.6 problem. That is not what you have.
If you are using a virtual environment (venv) in bookworm then you also
need to allow your venv to use system python module. You do not need to
install anything then and it will all just work when you import the module.
in your venv.
There is more I could add, but it's in the link topic and this thread id
not about kernel 6.6 so when you create your own topic etc, you'll need to give details of what device you are on, what OS you are using and how you are using Python.
AND all the errors it gives you.
The errors I can see just screams out that you are in a venv and have not allowed system-wide-module into the venv.
Go to the Pi forums and ask there for more detailed help with Python and
Bookworm itself.
Again, this has nothing to do with Kernel 6.6.20 * (well RPi.GPIO partly, but not lgpio which it should default to, I am of course guessing what you have and your setup etc.)
Do not install gpiozero, nor lgpio into your venv.
…On Mon, 25 Mar 2024 at 20:13, Matyas Forian-Szabo ***@***.***> wrote:
hm I dont understand, the error says that I have the NativePinFactory
running, whats the problem with that?
But I guess, I'll abandon using this library, I just need manual GPIO
control, and this seems like a classroom project hardcoded with tons of
stuff I dont need.
Anyone knows the most performant GPIO library that actually works with the
latest Pi update? Whats out:
- Rpi.gpio -- broke a few days ago.
- wiringpi -- not supported since 2019.
- this one -- its native implementation doesnt seem to work and I just
need the low level stuff anyway.
- pigpio -- looks good, again a bit bloated for me. I just need to
turn pins on/off, not running some daemons and remote debugging :(.
- lgpio -- doesnt seem to have a proper upload on pypi, no release
since 2020. Also might not work with virtualenv?
tbh I dont understand why the pi foundation thought it would be OK to
break the few easy to use libraries overnight without warning.
—
Reply to this email directly, view it on GitHub
<#1131 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACYAXN33RVBKN76F2KLRNN3Y2CANFAVCNFSM6AAAAABFBBJVYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJYHAZDQMZYGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
My mistake, I had forgotten that I was forking by using Process, and it was that was generating the GPIO busy, even though the Process wasnt using any GPIO and it appears to be the way lgpio library starts up. Switched it to a Thread() to run in-process an it disappeared; the process was doing an upload of mp4 files, which are IO bound and so it is OK to run as a Thread rather than a Process(). |
Hello, I faced a similar issue after upgrading my Linux kernel. Here's how I fixed it on my side :
If you get some import errors from
It means your
Hopefully that helps! 😄 |
According to raspberrypi/linux#6037 (comment) |
I have a Python project that worked fine on a Raspberry Pi Zero 2W, using Button() and LightSensor() when on Raspbian Bookworm and Linux kernel v6.1.0. I recently (March 16th 2024) apt upgrade to kernel v6.6.20 and now the same python code fails with the following stack trace:
File "/home/danny/camera_with_switch/lib/python3.11/site-packages/gpiozero/devices.py", line 108, in call
self = super().call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/danny/camera_with_switch/lib/python3.11/site-packages/gpiozero/input_devices.py", line 412, in init
super().init(
File "/home/danny/camera_with_switch/lib/python3.11/site-packages/gpiozero/mixins.py", line 417, in init
super().init(*args, **kwargs)
File "/home/danny/camera_with_switch/lib/python3.11/site-packages/gpiozero/input_devices.py", line 168, in init
self.pin.when_changed = self._pin_changed
^^^^^^^^^^^^^^^^^^^^^
File "/home/danny/camera_with_switch/lib/python3.11/site-packages/gpiozero/pins/init.py", line 471, in
lambda self, value: self._set_when_changed(value),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/danny/camera_with_switch/lib/python3.11/site-packages/gpiozero/pins/pi.py", line 639, in _set_when_changed
self._enable_event_detect()
File "/home/danny/camera_with_switch/lib/python3.11/site-packages/gpiozero/pins/rpigpio.py", line 220, in _enable_event_detect
GPIO.add_event_detect(
RuntimeError: Failed to add edge detection
dmesg also has an entry:
[ 187.151266] export_store: invalid GPIO 18
This was after a fresh reboot.
uname -a output:
Linux conservatory-cam 6.6.20+rpt-rpi-v7 #1 SMP Raspbian 1:6.6.20-1+rpt1 (2024-03-07) armv7l GNU/Linux
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 12 (bookworm)"
NAME="Raspbian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=raspbian
ID_LIKE=debian
The text was updated successfully, but these errors were encountered: