ubopod / ubo-hal

This repo includes code for communicating and interfacing with Ubo hardware peripherals
GNU General Public License v3.0
1 stars 2 forks source link

Fresh install of SDK has missing packages when running hello.py as well as some config/code issues #14

Open neoskedar opened 10 months ago

neoskedar commented 10 months ago

A fresh pull of the the SDK from the repository runs into the following errors when installing from install.sh on a new Raspbian install.

Fresh install of latest Raspbian does have Python 3.11 as the default version $ python --version Python 3.11.2

Install.sh gives warning bout not being able to create venv - need to run sudo apt install python3-venv and also gives a package warning E: Package 'python-all-dev' has no installation candidate

When attempting to run hello.py we start to find missing dependencies: source ~/ubo-venv/bin/activate (ubo-venv) pi@raspberrypiAI:~/ubo-sdk $ python3 hello.py Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 13, in <module> import board ModuleNotFoundError: No module named 'board'

This is rectified by installing Adafruit Blinka - pip3 install adafruit-blinka however, this also gives an error for the wheel, so you must first install python3-dev apt-get install python3-dev

once these are installed, running hello.py again now gives the following error: (ubo-venv) pi@raspberrypiAI:~/ubo-sdk $ python3 hello.py Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 18, in <module> from ubo_keypad.ubo_keypad import KEYPAD as KEYPAD File "/home/pi/ubo-sdk/ubo_keypad/ubo_keypad.py", line 3, in <module> import adafruit_aw9523 ModuleNotFoundError: No module named 'adafruit_aw9523'

This is rectified by running install adafruit-circuitpython-aw9523

Now running hello.py returns this error: python3 hello.py Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 18, in <module> from ubo_keypad.ubo_keypad import KEYPAD as KEYPAD File "/home/pi/ubo-sdk/ubo_keypad/ubo_keypad.py", line 16, in <module> logging.config.fileConfig(LOG_CONFIG, File "/usr/lib/python3.11/logging/config.py", line 71, in fileConfig formatters = _create_formatters(cp) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/logging/config.py", line 118, in _create_formatters c = _resolve(class_name) ^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/logging/config.py", line 89, in _resolve found = __import__(used) ^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'pythonjsonlogger' Rectified by running pip3 install python-json-logger

Now, hello.py returns the following error: python3 hello.py Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 18, in <module> from ubo_keypad.ubo_keypad import KEYPAD as KEYPAD ImportError: cannot import name 'KEYPAD' from 'ubo_keypad.ubo_keypad' (/home/pi/ubo-sdk/ubo_keypad/ubo_keypad.py)

I believe this error is due to case sensitivity. In the uno_keypad.py file, the class which is on line 80 is labeled as class Keypad: updating line 18 in hello.py to from ubo_keypad.ubo_keypad import Keypad as KEYPAD fixes this error. This appears to have been changed with the refactoring of the ubo_keypad.py in commit 103b337 as commit 23b65b8 still has the line class KEYPAD(object): on line 20, where as that line was removed in commit 103b337 and the class is now class Keypad: online ~76 but varies through later commits due to some refactoring. Class should be renamed KEYPAD or hello.py updated to Keypad. Not sure what your preferred method would be.

Once resolved, the next error is: python3 hello.py Possibly unsupported board: No module named 'adafruit_rgb_display' Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 19, in <module> from display.lcd import LCD as LCD File "/home/pi/ubo-sdk/display/lcd.py", line 11, in <module> from PIL import Image ModuleNotFoundError: No module named 'PIL'

This is corrected with pip3 install Pillow==9.5.0 This version must be install due to the removal of the getsize attribute in later versions which is used by lcd.py

Next error is: python3 hello.py Possibly unsupported board: No module named 'adafruit_rgb_display' Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 19, in <module> from display.lcd import LCD as LCD File "/home/pi/ubo-sdk/display/lcd.py", line 15, in <module> import qrcode ModuleNotFoundError: No module named 'qrcode'

Again, this is easily corrected by running pip3 install qrcode

This now returns: python3 hello.py Possibly unsupported board: No module named 'adafruit_rgb_display' Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 25, in <module> import demos.tone File "/home/pi/ubo-sdk/demos/tone.py", line 3, in <module> import pysine ModuleNotFoundError: No module named 'pysine' ' We correct the possibly unsupported board error by running the following commands: pip3 install adafruit-circuitpython-rgb-display pip3 install --upgrade --force-reinstall spidev

Attempting to run pip3 install pysine will return the following error: ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects This must be prefaced by first running sudo apt install portaudio19-dev. After that, pip3 install pysine will work with no issues

The next error is: Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 26, in <module> import demos.wav File "/home/pi/ubo-sdk/demos/wav.py", line 1, in <module> import pygame ModuleNotFoundError: No module named 'pygame'

This is corrected by running pip3 install pygame

Next, we encounter: Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 28, in <module> import demos.light File "/home/pi/ubo-sdk/demos/light.py", line 2, in <module> import adafruit_veml7700 ModuleNotFoundError: No module named 'adafruit_veml7700'

This is corrected by pip3 install adafruit-circuitpython-veml7700

We now received the error: ModuleNotFoundError: No module named 'adafruit_pct2075'

This is corrected by: pip3 install adafruit-circuitpython-pct2075

After this the unit will boot with no errors and show Continue? with a yes or no on the screen. However attempting to push the buttons results in a new error. Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 114, in key_press_cb button = self.BUTTONS[index] ^^^^^^^^^^^^ AttributeError: 'state_machine' object has no attribute 'BUTTONS'

This error is due to removing the code: self.BUTTONS = ["0", "1", "2", "up", "down", "back", "home", "mic"] in commit 103b337.

This is corrected by inserting that code in the ubo_keypad.py inside the def iinit function within the KEYPAD class

At this point, navigating the menus, The "Blinks" menu, will output text to the console, but the lights don't light up Investigation shows the rib-ring service is in failed state: `sudo systemctl status rgb-ring × rgb-ring.service - Ubo LED Service Loaded: loaded (/etc/systemd/system/rgb-ring.service; enabled; preset: enabled) Active: failed (Result: exit-code) since Fri 2023-10-27 13:20:13 MST; 29s ago Duration: 111ms Process: 1452 ExecStart=/home/pi/ubo-venv/bin/python3 /home/pi/ubo-sdk/rgb_ring/rgb_ring_manager.py (code=exited, status=1/FAILURE) Main PID: 1452 (code=exited, status=1/FAILURE) CPU: 111ms

Oct 27 13:20:13 raspberrypiAI systemd[1]: rgb-ring.service: Scheduled restart job, restart counter is at 5. Oct 27 13:20:13 raspberrypiAI systemd[1]: Stopped rgb-ring.service - Ubo LED Service. Oct 27 13:20:13 raspberrypiAI systemd[1]: rgb-ring.service: Start request repeated too quickly. Oct 27 13:20:13 raspberrypiAI systemd[1]: rgb-ring.service: Failed with result 'exit-code'. Oct 27 13:20:13 raspberrypiAI systemd[1]: Failed to start rgb-ring.service - Ubo LED Service.`

Attempting to run rgb_ring_manager.py manually results in the following error: python3 rgb_ring_manager.py Traceback (most recent call last): File "/home/pi/ubo-sdk/rgb_ring/rgb_ring_manager.py", line 5, in <module> import neopixel ModuleNotFoundError: No module named 'neopixel'

This is corrected by running pip3 install adafruit-circuitpython-neopixel

Restarting the service and statusing it now shows the service running as expected: `sudo systemctl restart rgb-ring (ubo-venv) pi@raspberrypiAI:~/ubo-sdk/rgb_ring $ sudo systemctl status rgb-ring ● rgb-ring.service - Ubo LED Service Loaded: loaded (/etc/systemd/system/rgb-ring.service; enabled; preset: enabled) Active: active (running) since Fri 2023-10-27 13:28:32 MST; 2s ago Main PID: 1500 (python3) Tasks: 2 (limit: 8741) CPU: 191ms CGroup: /system.slice/rgb-ring.service └─1500 /home/pi/ubo-venv/bin/python3 /home/pi/ubo-sdk/rgb_ring/rgb_ring_manager.py

Oct 27 13:28:32 raspberrypiAI systemd[1]: Started rgb-ring.service - Ubo LED Service. Oct 27 13:28:32 raspberrypiAI python3[1500]: rgb_ring_manager.py:261 - INFO: ---executing command--- Oct 27 13:28:32 raspberrypiAI python3[1500]: LED Manager opening socket... Oct 27 13:28:32 raspberrypiAI python3[1500]: 0x100 Oct 27 13:28:32 raspberrypiAI python3[1500]: 0x1b4 Oct 27 13:28:32 raspberrypiAI python3[1500]: LED Manager Listening... Oct 27 13:28:32 raspberrypiAI python3[1500]: rgb_ring_manager.py:261 - INFO: ---executing command---`

The Blink functions now all work with no issue.

All items in the "Beeps" menu work with no issues

Within the "Sensors" menu, the Light and Temperature options work, but the Microphone returns the following error: Traceback (most recent call last): File "/home/pi/ubo-sdk/hello.py", line 167, in key_press_cb self.launch_demo("mic") File "/home/pi/ubo-sdk/hello.py", line 188, in launch_demo eval("demos." + demo + ".demo")() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<string>", line 1, in <module> AttributeError: module 'demos' has no attribute 'mic'

This appears to be an issue due to mic demo existing, so this is expected behavior.

Last couple things noticed is that attempting to run the clock.py demo we need to install a few modules pip3 install pyttsx3' pip3 install pydub sudo apt install espeak

After all of these items, here is a current output of my installed pip packages, that we can possibly source to make a new requirements.txt file

Adafruit-Blinka==8.24.0 adafruit-circuitpython-aw9523==1.1.8 adafruit-circuitpython-busdevice==5.2.6 adafruit-circuitpython-neopixel==6.3.10 adafruit-circuitpython-pct2075==1.1.20 adafruit-circuitpython-pixelbuf==2.0.3 adafruit-circuitpython-register==1.9.17 adafruit-circuitpython-requests==2.0.2 adafruit-circuitpython-rgb-display==3.12.2 adafruit-circuitpython-typing==1.9.5 adafruit-circuitpython-veml7700==1.1.21 Adafruit-PlatformDetect==3.53.0 Adafruit-PureIO==1.1.11 certifi==2022.9.24 chardet==5.1.0 charset-normalizer==3.0.1 colorzero==2.0 distro==1.8.0 gpiozero==2.0 idna==3.3 lgpio==0.2.2.0 mock==5.1.0 nose==1.3.7 numpy==1.26.1 pigpio==1.78 Pillow==9.5.0 PyAudio==0.2.13 pydub==0.25.1 pyftdi==0.55.0 pygame==2.5.2 pypng==0.20220715.0 pyserial==3.5 pysine==0.9.2 python-apt==2.6.0 python-json-logger==2.0.7 pyttsx3==2.90 pyusb==1.2.1 qrcode==7.4.2 requests==2.28.1 rpi-ws281x==5.0.0 RPi.GPIO==0.7.1a4 six==1.16.0 smbus2==0.4.2 spidev==3.6 ssh-import-id==5.10 sysv-ipc==1.1.0 toml==0.10.2 typing_extensions==4.8.0 urllib3==1.26.12

neoskedar commented 10 months ago

In the install.sh the line to install the requirements.txt looks to be incorrect python3.9 -m pip install -r $UBO_HOME/system/setup/requirements.txt

It should be python3 not python3.9. Correcting this allows the requirements.txt to install. This may correct a lot of the issues on a fresh install.

zytegalaxy commented 10 months ago

Thanks so much for the feedback! and apologies for the delay to resolve these issues. I am planning to do a fresh install in the next few days and address all open issues.

BTW, may I ask which Raspberry Pi OS version you started with? Can you please run uname -a command and let me know the output?

I am planning to test the SDK on Raspberry Pi 5 (got one a few days ago) and Debian Bookworm...

neoskedar commented 10 months ago

(ubo-venv) pi@raspberrypiAI:~/ubo-sdk $ uname -a Linux raspberrypiAI 6.1.0-rpi4-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.54-1+rpt2 (2023-10-05) aarch64 GNU/Linux