Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: After upgrading to 9.3 my own Python scripts stopped working
#1
After upgrading to 9.3, I noticed that the fan control scripts for my Rpi and the LED blinking control script during music playback stopped working.
I use Moode since version 8 and have never encountered this before.
The scripts were launched at system startup using the rc.local file. 

Now, when trying to run scripts in the command line I get errors even though the syntax is correct.

Please, help.

P.S. Scripts are attached.


Attached Files
.zip   Scripts.zip (Size: 2.02 KB / Downloads: 6)
Reply
#2
Please post the errors.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(04-04-2025, 08:44 PM)Tim Curtis Wrote: Please post the errors.

This script works fine with version 9.2 and earlier.

With version 9.3 I have this.

moode@moode:~ $ sudo python3 /home/moode/fan_ctrl.py
Traceback (most recent call last):
  File "/home/moode/fan_ctrl.py", line 9, in <module>
    GPIO.setup(17, GPIO.OUT)
  File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 704, in setup
    initial = _check(lgpio.gpio_read(_chip, gpio))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lgpio.py", line 903, in gpio_read
    return _u2i(_lgpio._gpio_read(handle&0xffff, gpio))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
    raise error(error_text(v))
lgpio.error: 'GPIO not allocated'
Reply
#4
(04-04-2025, 08:50 PM)svitalya Wrote:
(04-04-2025, 08:44 PM)Tim Curtis Wrote: Please post the errors.

This script works fine with version 9.2 and earlier.

With version 9.3 I have this.

moode@moode:~ $ sudo python3 /home/moode/fan_ctrl.py
Traceback (most recent call last):
  File "/home/moode/fan_ctrl.py", line 9, in <module>
    GPIO.setup(17, GPIO.OUT)
  File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 704, in setup
    initial = _check(lgpio.gpio_read(_chip, gpio))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lgpio.py", line 903, in gpio_read
    return _u2i(_lgpio._gpio_read(handle&0xffff, gpio))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
    raise error(error_text(v))
lgpio.error: 'GPIO not allocated'

Are the scripts already running in the background (after being started because of the added lines in rc..local)?

If so they own the gpio lines in question. They can't be allocated again by a script started from the command line.

To test this, I tried your scripts from the command line before I copied the two new lines into /etc/rc.local and they ran fine.

Then I added the lines in /etc/rc.local and rebooted.

'ps aux' showed the two scripts are running and now I get the same error you do if I try also to run the scripts from the command line.

Regards,
Kent
Reply
#5
(04-05-2025, 01:56 AM)TheOldPresbyope Wrote:
(04-04-2025, 08:50 PM)svitalya Wrote:
(04-04-2025, 08:44 PM)Tim Curtis Wrote: Please post the errors.

This script works fine with version 9.2 and earlier.

With version 9.3 I have this.

moode@moode:~ $ sudo python3 /home/moode/fan_ctrl.py
Traceback (most recent call last):
  File "/home/moode/fan_ctrl.py", line 9, in <module>
    GPIO.setup(17, GPIO.OUT)
  File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 704, in setup
    initial = _check(lgpio.gpio_read(_chip, gpio))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lgpio.py", line 903, in gpio_read
    return _u2i(_lgpio._gpio_read(handle&0xffff, gpio))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
    raise error(error_text(v))
lgpio.error: 'GPIO not allocated'

Are the scripts already running in the background (after being started because of the added lines in rc..local)?

If so they own the gpio lines in question. They can't be allocated again by a script started from the command line.

To test this, I tried your scripts from the command line before I copied the two new lines into /etc/rc.local and they ran fine.

Then I added the lines in /etc/rc.local and rebooted.

'ps aux' showed the two scripts are running and now I get the same error you do if I try also to run the scripts from the command line.

Regards,
Kent


Thank you, Kent!

I checked the scripts loading using 'ps aux'. Yes, they were indeed in memory, but for some reason they did not work properly.
Then I decided the problem is not in Moode and reinstalled the system. After installing a clean system, the problem was solved.

I'm really sorry for wasting your time.

Thank you!
Reply


Forum Jump: