helgeerbe / picframe

Picture frame viewer for raspi, controlled via mqtt and automatticly integrated as mqtt device in homeassistant.
MIT License
113 stars 32 forks source link

Raspberry Pi Buster no longer available for download #333

Closed sapnho closed 3 weeks ago

sapnho commented 1 year ago

I have just been contacted by a blog reader who told me that Raspberry Pi Buster is no longer available for download.

I will start experimenting with Bookworm on a Pi4 this weekend to see what still works and what might be broken in Pi3D PictureFrame.

sapnho commented 1 year ago

Ok, I have started the check. Downloaded and installed Bookworm with Desktop on a Pi 4. So far so good. Screen Blanking is D4 now (was D2 before) but that doesn't matter.

Heading over to my blog article on the installation of Pi3D.

sudo raspi-config nonint do_boot_behaviour B2 && sudo raspi-config nonint do_memory_split 512 && sudo raspi-config needs to have the do_memory_split 512 removed. Can't find that anymore in the raspi config menu. Maybe this is automatic now?

When I then enter the first installation command

pi@pi4test:~ $ sudo python3 -m pip install -U pip

I get

error: externally-managed-environment

× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

For more information visit http://rptl.io/venv

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.

sapnho commented 1 year ago

So, I guess, there's some work to do to get Pi3D running on Bookworm...

sapnho commented 1 year ago

So, it seems like Python packages in Bookworm must now be installed in a virtual environment.

I did python3 -m venv myenv andsource myenv/bin/activate which then allows me to pip install picframe.

This resulted in Successfully installed IPTCInfo3-2.1.4 Pillow-9.5.0 PyYAML-6.0.1 defusedxml-0.7.1 ninepatch-0.1.22 numpy-1.26.1 paho-mqtt-1.6.1 pi-heif-0.13.0 pi3d-2.49 picframe-2023.7.26.post1 So far, so good.

sapnho commented 1 year ago

Entering picframe -i . however, then results in a mouthful.

Traceback (most recent call last): File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/init.py", line 24, in from . import multiarray File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/multiarray.py", line 10, in from . import overrides File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/overrides.py", line 8, in from numpy.core._multiarray_umath import ( ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/pi/myenv/lib/python3.11/site-packages/numpy/init.py", line 130, in from numpy.config import show as show_config File "/home/pi/myenv/lib/python3.11/site-packages/numpy/config.py", line 4, in from numpy.core._multiarray_umath import ( File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/init.py", line 50, in raise ImportError(msg) ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.

Original error was: libopenblas.so.0: cannot open shared object file: No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/pi/myenv/bin/picframe", line 5, in from picframe.start import main File "/home/pi/myenv/lib/python3.11/site-packages/picframe/start.py", line 8, in from picframe import model, viewer_display, controller, version File "/home/pi/myenv/lib/python3.11/site-packages/picframe/viewer_display.py", line 1, in import pi3d File "/home/pi/myenv/lib/python3.11/site-packages/pi3d/init.py", line 19, in from pi3d.Buffer import Buffer File "/home/pi/myenv/lib/python3.11/site-packages/pi3d/Buffer.py", line 4, in import numpy as np File "/home/pi/myenv/lib/python3.11/site-packages/numpy/init.py", line 135, in raise ImportError(msg) from e ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there. (myenv) pi@pi4test:~ $ picframe -i . Traceback (most recent call last): File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/init.py", line 24, in from . import multiarray File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/multiarray.py", line 10, in from . import overrides File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/overrides.py", line 8, in from numpy.core._multiarray_umath import ( ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/pi/myenv/lib/python3.11/site-packages/numpy/init.py", line 130, in from numpy.config import show as show_config File "/home/pi/myenv/lib/python3.11/site-packages/numpy/config.py", line 4, in from numpy.core._multiarray_umath import ( File "/home/pi/myenv/lib/python3.11/site-packages/numpy/core/init.py", line 50, in raise ImportError(msg) ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.

Original error was: libopenblas.so.0: cannot open shared object file: No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/pi/myenv/bin/picframe", line 5, in from picframe.start import main File "/home/pi/myenv/lib/python3.11/site-packages/picframe/start.py", line 8, in from picframe import model, viewer_display, controller, version File "/home/pi/myenv/lib/python3.11/site-packages/picframe/viewer_display.py", line 1, in import pi3d File "/home/pi/myenv/lib/python3.11/site-packages/pi3d/init.py", line 19, in from pi3d.Buffer import Buffer File "/home/pi/myenv/lib/python3.11/site-packages/pi3d/Buffer.py", line 4, in import numpy as np File "/home/pi/myenv/lib/python3.11/site-packages/numpy/init.py", line 135, in raise ImportError(msg) from e ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there.

paddywwoof commented 1 year ago

Forcing virtual env seems like a big departure from previously. There will need to be a massive rewrite of documentation all over the place, not just for picframe and pi3d!

sapnho commented 1 year ago

Could tools like Replin help in the conversion? I was generating and testing several Python scripts with ChatGPT yesterday to see how well they work, and I was blown away by the result.

Also, just checked out Replin, which is like Copilot but (apparently) a lot better. It even has a free option.

sapnho commented 1 year ago

Forcing virtual env seems like a big departure from previously. There will need to be a massive rewrite of documentation all over the place, not just for picframe and pi3d!

What is the biggest impact of this virtual environment?

paddywwoof commented 1 year ago

Virtual envs good for doing different things with a computer (especially different dependencies or python versions). However for a dedicated application like picframe they're an extra layer of complexity.

The main issue will be all the documentation and examples on line where pip install x stops working

sapnho commented 1 year ago

Hmm, that's a bummer. I guess then at the moment, there is no way to use Pi3D with the current RPI OS anymore.

It's astonishing how many breaking changes OS changes introduce.

paddywwoof commented 1 year ago

It doesn't seem too bad. There might be one or two things needing to be fine tuned, but I have just done this and it all seems OK: 1. Put~bullseye~bookworm on an SD card then stick it in an RPi4 2. Log in, open a terminal and git clone pi3d and pi3d_demos 3. cd to pi3d_demos and python3 RunTests.py Not sure about FPS but didn't look too bad, obviously should have set GPU driver, memory and all the other fine details, but it seems a positive start.

Paddy

paddywwoof commented 1 year ago

Hmm. As you say, these OS upgrades are full of breaking changes.

I've tried pip installing pi3d and, as you discovered, this has now become non-trivial. I had to use venv and had to specify source on github: python -m pip install git+https://github.com/tipam/pi3d having gradually discovered that python has changed from being an alias for python2 to python3. However the dependency in pi3d.setup.py for numpy downloads and installs version 1.26.1 although 1.24 is already installed with bookworm. And the pip installed version of numpy is missing the compiled libraries for blas... Surely this problem will have happened with lots of other people! Anyway, I think we need to specify the debian python3-numpy rather than whatever pip dredges up!

PS Some progress: At least with testing pi3d as above, if I delete the environment I created earlier and recreate it using the --system-site-packages option it seems to work (I didn't change my user name as instructed during setup!)

(venv) pi@raspberrypi:~ $ deactivate
pi@raspberrypi:~ $ rm -r venv
pi@raspberrypi:~ $ python -m venv --system-site-packages venv
pi@raspberrypi:~ $ source /home/pi/venv/bin/activate
(venv) pi@raspberrypi:~ python -m pip install git+https://github.com/tipam/pi3d

NB To stop the demos using the version of pi3d in /home/pi/pi3d, if you cloned it there, you need to $ mv ~/pi3d_demos/demo.py ~/pi3d_demos/demo.tmp

This does mean there will probably need work-arounds for picframe installation because we ask for specific version number of some packages, possibly not using the debian site package. More testing, then, when picframe seems to work I will start to see if we can manage without the desktop!!

Paddy

paddywwoof commented 1 year ago

One quirk I've found, that might be related to @helgeerbe's work getting pi3d to run on the mac, is that I have to set use_glx=True if I try to start a demo program over SSH. Most demos will run if started locally even without use_glx apart from TriceratopsModel which just hangs. One or two, such as TigerTank start but then freeze the process inescapably.

sapnho commented 1 year ago

One quirk I've found, that might be related to @helgeerbe's work getting pi3d to run on the mac, is that I have to set use_glx=True if I try to start a demo program over SSH. Most demos will run if started locally even without use_glx apart from TriceratopsModel which just hangs. One or two, such as TigerTank start but then freeze the process inescapably.

I guess the key is to get it going on the Pi, so that's probably a sacrifice to make. :-)

sapnho commented 1 year ago

Ok, so I just did a clean install with bullseye on a Pi 4.

I encountered the first difference

In the raspi-config module, go to 6 Advanced Options > A2 GL Driver > Choose G2 GL Fake KMS.

There is no fake driver anymore. Just an experimental Wayland backend.

Pi3D installation seems to have worked but gave a few warnings:

pi@pi4bullseye:~ $ sudo python3 -m pip install -U pip Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: pip in /usr/lib/python3/dist-packages (20.3.4) Collecting pip Downloading https://www.piwheels.org/simple/pip/pip-23.3-py3-none-any.whl (2.1 MB) |████████████████████████████████| 2.1 MB 1.1 MB/s Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.3.4 Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr Can't uninstall 'pip'. No files were found to uninstall. Successfully installed pip-23.3

pi@pi4bullseye:~ $ sudo python3 -m pip install pi-heif Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting pi-heif Downloading pi_heif-0.13.1-cp39-cp39-manylinux_2_28_armv7l.whl.metadata (6.1 kB) Collecting pillow>=9.1.1 (from pi-heif) Downloading https://www.piwheels.org/simple/pillow/Pillow-10.1.0-cp39-cp39-linux_armv7l.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 3.9 MB/s eta 0:00:00 Downloading pi_heif-0.13.1-cp39-cp39-manylinux_2_28_armv7l.whl (625 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 625.3/625.3 kB 5.4 MB/s eta 0:00:00 DEPRECATION: gpg 1.14.0-unknown has a non-standard version number. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of gpg or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063 Installing collected packages: pillow, pi-heif Attempting uninstall: pillow Found existing installation: Pillow 8.1.2 Uninstalling Pillow-8.1.2: Successfully uninstalled Pillow-8.1.2 Successfully installed pi-heif-0.13.1 pillow-10.1.0 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

pi@pi4bullseye:~ $ sudo pip3 install picframe Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting picframe Downloading https://www.piwheels.org/simple/picframe/picframe-2023.7.26.post1-py3-none-any.whl (3.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 3.8 MB/s eta 0:00:00 Collecting Pillow==9.5.0 (from picframe) Downloading https://www.piwheels.org/simple/pillow/Pillow-9.5.0-cp39-cp39-linux_armv7l.whl (1.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 3.9 MB/s eta 0:00:00 Collecting defusedxml (from picframe) Downloading https://www.piwheels.org/simple/defusedxml/defusedxml-0.7.1-py2.py3-none-any.whl (25 kB) Collecting pi3d>=2.49 (from picframe) Downloading https://www.piwheels.org/simple/pi3d/pi3d-2.49-py3-none-any.whl (270 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 270.8/270.8 kB 4.0 MB/s eta 0:00:00 Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from picframe) (5.3.1) Collecting paho-mqtt (from picframe) Downloading https://www.piwheels.org/simple/paho-mqtt/paho_mqtt-1.6.1-py3-none-any.whl (75 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.6/75.6 kB 3.0 MB/s eta 0:00:00 Collecting IPTCInfo3 (from picframe) Downloading https://www.piwheels.org/simple/iptcinfo3/IPTCInfo3-2.1.4-py3-none-any.whl (12 kB) Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from picframe) (1.19.5) Collecting ninepatch (from picframe) Downloading ninepatch-0.1.22-py3-none-any.whl (16 kB) Requirement already satisfied: pi-heif>=0.8.0 in /usr/local/lib/python3.9/dist-packages (from picframe) (0.13.1) DEPRECATION: gpg 1.14.0-unknown has a non-standard version number. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of gpg or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063 Installing collected packages: paho-mqtt, IPTCInfo3, Pillow, defusedxml, pi3d, ninepatch, picframe Attempting uninstall: Pillow Found existing installation: Pillow 10.1.0 Uninstalling Pillow-10.1.0: Successfully uninstalled Pillow-10.1.0 Successfully installed IPTCInfo3-2.1.4 Pillow-9.5.0 defusedxml-0.7.1 ninepatch-0.1.22 paho-mqtt-1.6.1 pi3d-2.49 picframe-2023.7.26.post1 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

pi@pi4bullseye:~ $ picframe -i . INFO:start.py:starting ['/usr/local/bin/picframe', '-i', '.'] This will configure /home/pi/picframe_data/config/configuration.yaml To keep default, just hit enter Enter picture directory [~/Pictures]: Enter picture directory [~/DeletedPictures]: Enter locale [en_GB.UTF-8]: created /home/pi/picframe_data

Starting Pi3D with

pi@pi4bullseye:~ $ sudo xinit /usr/bin/python3 /home/pi/picframe_data/run_start.py /home/pi/picframe_data/config/configuration.yaml

gave this:

X.Org X Server 1.20.11 X Protocol Version 11, Revision 0 Build Operating System: linux Raspbian Current Operating System: Linux pi4bullseye 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_hdmi=0 video=HDMI-A-1:1920x1080M@60 smsc95xx.macaddr=E4:5F:01:8D:66:33 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyS0,115200 console=tty1 root=PARTUUID=1dcecdd5-02 rootfstype=ext4 fsck.repair=yes rootwait Build Date: 30 March 2023 01:46:14PM xorg-server 2:1.20.11-1+rpt3+deb11u6 (https://www.debian.org/support) Current version of pixman: 0.40.0 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.0.log", Time: Sat Oct 21 10:22:59 2023 (==) Using config directory: "/etc/X11/xorg.conf.d" (==) Using system config directory "/usr/share/X11/xorg.conf.d" error: XDG_RUNTIME_DIR not set in the environment. DRM_IOCTL_MODE_CREATE_DUMB failed: Cannot allocate memory Failed to create scanout resource (EE) Fatal server error: (EE) AddScreen/ScreenInit failed for driver 0 (EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information. (EE) (EE) Server terminated with error (1). Closing log file. xinit: giving up xinit: unable to connect to X server: Connection refused xinit: server error

I guess that's a result of the graphic driver.

paddywwoof commented 1 year ago

OK I've been looking a bit more into bookworm as that's got the new wayland back end. As I said above it works to some extent but not all the time and with issues, especially over SSH. Also the frames 'tear' which is probably due to pi3d not waiting for the full render to complete before allowing the next. This didn't seem to be a problem with the old drivers but it is now - I can probably fix it by just adding a single line in DisplayOpenGL.py.

I couldn't get pi3d to work from the 'lite' version of bookworm following the instructions from @thomasedoff it probably either needs wayland related installs or the switch in raspi-config needs to be set to X11 instead of wayland.

However SDL2 for bookworm will render to the screen without the desktop, at least using rust_pi3d. So I'm going to try setting up SDL2 as the windowing system for python pi3d and see how that goes.

PS to test the SDL2 option I started with the 'lite' bookworm SD then

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install libsdl2-dev
#### install rust
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ sudo reboot
#### download and compile rust_pi3d
$ sudo apt install git
$ git clone https://github.com/paddywwoof/rust_pi3d
$ cd rust_pi3d/pi3d
$ cargo build --release --examples
#### run examples: minimal, game, forest_walk, farris, picture_frame, shader_in_src, ship_demo, tsp - ESC to quit
$ rust_pi3d/pi3d/target/release/examples/minimal

PS It looks like I already did much of this work four years ago!! https://github.com/tipam/pi3d/compare/master...sdl2

paddywwoof commented 1 year ago

So this is what I did next, and pi3d seems to run OK (though nowhere near the FPS of rust_pi3d)

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install libsdl2-dev python3-numpy python3-pil python3-pip git
$ python -m pip install pysdl2 --break-system-packages ## really should use venv or some other option!*
$ cd ~
$ git clone https://github.com/tipam/pi3d
$ cd pi3d
$ git checkout sdl2 ## use sdl2 branch
$ cd ~
$ git clone https://github.com/pi3d/pi3d_demos
$ cd pi3d_demos
## edit ForestWalk.py, say, and change
  DISPLAY = pi3d.Display.create(x=100, y=100, frames_per_second=30, use_sdl2=True)
##
$ python ForestWalk.py

PS spoke too soon... works well on RPi3 but not on RPi4. No error, keyboard input seems to work (probably mouse too) but no graphics. NB this is only starting without the desktop, if I open a terminal from RPi4 desktop the SDL2 branch works PPS there is an option to sudo apt install python3-sdl2

paddywwoof commented 1 year ago

I've got a workable system: For the Pi up to and including 3 I can run from the command line with SDL2, for the Pi 4 (and 5, who knows?) it runs using xinit. Once we've tested it, the sdl2 branches will be merged into main so the local install steps will be simplified. However the new system of venv seems fraught and I couldn't get it to work without scrambling the modules, so used --break-system-packages, which doesn't sound very promising but seems to work.

  1. Flash SD with bookworm lite and set county, language, user, password, wifi, boot. (I didn't change anything else in raspi-config as I had an ethernet connection and connected keyboard)
  2. apt install the libraries for either <3 or 4+
    sudo apt update
    sudo apt upgrade
    sudo apt install python3-numpy python3-pil python3-pip git

    2.a. install libraries for SDL2 with Pi <3 - obviously this could be added to above command

    sudo apt install libsdl2-dev python3-sdl2

    2.b install X11 libraries and xinit application if Pi is 4 or 5

    sudo apt install xserver-xorg xserver-xorg-legacy xinit
  3. pi3d, sdl2 branch
    git clone https://github.com/tipam/pi3d
    cd pi3d
    git checkout sdl2
    cd ..
  4. picframe, sdl2 branch
    git clone https://github.com/helgeerbe/picframe
    cd picframe
    git checkout sdl2
    nano pyproject.toml
    # change dependency to "Pillow>=9.4.0"
    cd ..
  5. install pi3d and picframe from local repos
    python -m pip install file:///home/pi/pi3d --prefer-binary --break-system-packages
    python -m pip install file:///home/pi/picframe --prefer-binary --break-system-packages
    /home/pi/.local/bin/picframe -i /home/pi/ # accept defaults
    mkdir {Pictures,DeletedPictures}

    6.a Set config to use SDL2 and run in Pi <3

    nano ~/picframe_data/config/configuration.yaml
    # use_sdl2: True
    python /home/pi/.local/bin/picframe /home/pi/picframe_data/config/configuration.yaml

    6.b Can still set configuration use_sdl2: True but not needed for Pi 4+

    sudo nano /etc/X11/Xwrapper.config
    # change
    allowed_users=anybody
    needs_root_rights=yes
    # save
    xinit /usr/bin/python /home/pi/.local/bin/picframe /home/pi/picframe_data/config/configuration.yaml
sapnho commented 1 year ago

Thanks, Paddy. Will try this on the weekend.

rock-meister commented 1 year ago

Newbie alert! I am running it on Model 3B cat /proc/cpuinfo | grep ^Model Model : Raspberry Pi 3 Model B Rev 1.2

Here are a few minor issues Issue 1: Unable to set locale to en_US.UTF-8 ERROR:model.Model:error trying to set locale to en_US.UTF-8

Issue 2: mkdir {Pictures, DeletedPictures} doesn't work. It's creating 2 directories "{Pictures" and "DeletedPictures}"

Issue 3: Typo on 6.a filename coonfiguration.yaml should be configuration.yaml

After fixing those minor issues, it is running fine. Thanks everyone for all the hard work!

paddywwoof commented 1 year ago

@rock-meister thanks for testing and sorry for the typos which I've fixed. It's rather a 'work in progress' as git cloning, changing branch then pip installing locally is very clunky. (I'm not sure about the en_US but it should be possible to set this up at an earlier stage in raspi-config). I would really like to find a way for the SDL2 route to work on RPi 4 and 5 which would simplify the whole thing further. Short term it's really helpful of you to test the system on different setups.

sapnho commented 1 year ago

Just installed it on a Pi4 with Bookworm (64-bit with Desktop (the recommended version)) and it works. Will let it run for a while to see if it's stable. Thanks, @paddywwoof !

sapnho commented 1 year ago

The only unusual thing I can notice at this point, is when I add pictures on the fly while Pi3D is running, the I get this error

WARNING:get_image_meta.GetImageMeta:Cause: cannot identify image file '/home/pi/Pictures/2021. 09.15 - 12.46. 24 Fnatenrahmen.jpg'

However, the image is shown and the metadata are correct. And I think the error message came with the old version as well.

sapnho commented 1 year ago

@paddywwoof Can you test if the performance is the same? Not sure how would you measure it.

paddywwoof commented 1 year ago

Hi, I will check out that error, might be more checking for various things.. especially getting video working after a fashion.

I can test the frame rate on the RPi3 in the kitchen then update it to new stem and try that.

sapnho commented 1 year ago

BTW, this sudo apt install python3-numpy python3-pil python3-pip git does not seem to be necessary with the recommended Bookworm version. I get

python3-numpy is already the newest version (1:1.24.2-1). python3-pil is already the newest version (9.4.0-1.1+b1). python3-pil set to manually installed. python3-pip is already the newest version (23.0.1+dfsg-1+rpt1). git is already the newest version (1:2.39.2-1.1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

sapnho commented 1 year ago

And sudo apt install xserver-xorg xserver-xorg-legacy xinit only xserver-xorg-legacy needs to be installed.

xserver-xorg is already the newest version (1:7.7+23). xinit is already the newest version (1.4.0-1). The following NEW packages will be installed: xserver-xorg-legacy 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

sapnho commented 1 year ago

The only unusual thing I can notice at this point, is when I add pictures on the fly while Pi3D is running, the I get this error

WARNING:get_image_meta.GetImageMeta:Cause: cannot identify image file '/home/pi/Pictures/2021. 09.15 - 12.46. 24 Fnatenrahmen.jpg'

However, the image is shown and the metadata are correct. And I think the error message came with the old version as well.

I think this comes up because the file analysis is triggered before the full transfer of the file has actually taken place.

sapnho commented 1 year ago

I have started an post with your new instructions, @paddywwoof here: https://www.thedigitalpictureframe.com/how-to-build-a-gorgeous-digital-picture-frame-with-a-raspberry-pi-based-on-2023-bookworm/

Haven't tested it on the Pi3 yet.

Does this 2.a. install libraries for SDL2 with Pi <3 include the Pi 3 is it just for the Pi2?

paddywwoof commented 1 year ago

Hi, yes you're right, that should be Pi <=3 or Pi<4

Are you using the lite version of bookworm? I suppose it's not the end of the world if they're already there.

sapnho commented 1 year ago

I am using Raspberry Pi OS (64-bit) with the Raspberry Pi Desktop, which has "Recommended" in brackets. I always try to stay as close to the default settings, which avoids issues when readers try to follow the instructions.

And definitely not the end of the world. :-))))

sapnho commented 1 year ago

Just made a fresh install on a Pi 3. Also works as it should! :-)

helgeerbe commented 1 year ago

Hi, sorry I was away on a longer trip and hadn't time to write.

This is my shortest setup guide to run picframe on bookworm:

  1. Install bookworm desktop. I configured it as host=raspberrypi , user=pi and using wifi

  2. After first boot open terminal and run:

    sudo apt-get update 
    sudo apt-get full-upgrade 
    sudo reboot 
  3. sudo raspi config
    • 1 System Options -> S5 Boot -> B2 Sonsole Autologin as 'pi' user
    • 2 Display Option -> D2 Screen Blanking -> Disable Screen Blanking
    • 3 Interface Options -> I1 SSH -> Enable SSH
    • 5 Localisation Options -> L1 Locale -> de_DE.UTF-8 UTF-8 (or whatever what your country is)
    • 5 Localisation Options -> L2 Timezone -> Europe Berlin (or whatever your timezone is)
    • 5 Localisation Options -> L3 Keyboard -> my keboard layout
    • 6 Advanced Options -> A1 Expand Filesystem and reboot
  4. Install picframe using a virtual environment for python

    mkdir pvenv 
    python –v venv /home/pi/pvenv 
    source pvenv/bin/activate
    pip install picframe
    picframe –i .  

    5 create startscript that activates virtual python env nano start_picframe.sh

    #!/bin/bash
    source /home/pi/pvenv/bin/activate # activate phyton virtual env
    picframe &  #start picframe

    make script executable chmod +x start_picframe.sh

  5. create wayfire autostart nano .config/wayfire.ini and add or extend autostart section

    [autostart]
    picframe = bash $HOME/start_picframe.sh
  6. create user systemd service to start picframe on boot

    mkdir ~/.config/systemd/user/ -p
    nano ~/.config/systemd/user/picframe.service
    
    [Unit]
    Description=PictureFrame on Pi3

[Service] ExecStart=/usr/bin/wayfire Restart=always

[Install] WantedBy=default.target



8. Controlling the service

You have the following options:

- Enable service `systemctl --user enable picframe.service`
- Disable service `systemctl --user disable picframe.servcie`
- Start service `systemctl --user start picframe.service`
- Stop service `systemctl --user stop picframe.service`
- Stop restart `systemctl --user restart picframe.service`
- Check logfiles `journalctl --user-unit picframe.service`

Good: Easy setup. Starting stopping service works over ssh
Bad: Before the first image is displayed, you will see the desktop for a short time.  
sapnho commented 1 year ago

THanks much, @helgeerbe ! Is this for both Pi 3 and 4?

paddywwoof commented 1 year ago

Helge, that's great fixing the issues with venv.

In latest news: I've found the cause of SDL2 not working on the RPi 4+. Basically trying to set the depth buffer to 24 bits causes the problem, I'll check why, but it works without specifying anything. So that would mean one set of instructions and no need for any desktop, X11 or otherwise... However I've not yet found a way to blank the screen without X11. Hmm😕

helgeerbe commented 1 year ago

THanks much, @helgeerbe ! Is this for both Pi 3 and 4?

I tested it on Pi3. But there is nothing special, so I would assume this works with a Pi 4 as well.

But this setup uses xWayland. So its still an X application.

If @paddywwoof get the SDL support ready and we set SDL_VIDEODRIVER=wayland. It should run completely natively on wayland.

Anyhow, I found some hickups in my setup:

Performance seems to be (on Pi 3) the same, as under bulleseye.

paddywwoof commented 1 year ago

I've updated the SDL2 branch so it works with Piv4+ and, once I've done a little more testing I will merge into main and bump to v2.51.

I got a bit of a lead here https://forums.raspberrypi.com/viewtopic.php?t=358689 but doesn't seem to work so far. There is an option in SDL to enable and disable screen blanking so maybe we can set it to a short period in the setup then toggle with SDL... Who knows!

helgeerbe commented 1 year ago

@paddywwoof I tested the sdl branches and it works, without using X11 anymore.

What have I done:

I would assume that the same setup would work for Pi3, Pi4 and Pi5. Would be good, if someone can confirm this.

If this is working we should:

Maybe we should find out, what additional packages are needed, if you install the lite version

helgeerbe commented 1 year ago

commands to blank screen under wayland on/off are

wlr-randr --output HDMI-A-1 --off
wlr-randr --output HDMI-A-1 --on
paddywwoof commented 1 year ago

@rock-meister thanks for testing and sorry for the typos which I've fixed. It's rather a 'work in progress' as git cloning, changing branch then pip installing locally is very clunky. (I'm not sure about the en_US but it should be possible to set this up at an earlier stage in raspi-config). I would really like to find a way for the SDL2 route to work on RPi 4 and 5 which would simplify the whole thing further. Short term it's really helpful of you to test the system on different setups.

paddywwoof commented 1 year ago

@helgeerbe I've started trying to follow your instructions with a new SD but I can't really get past first base. I had to insert a step sudo apt install python3-venv but after pip install picframe I don't have any usable modules. numpy is missing the openblas library, PIL is missing various components, pi3d can't find the OpenGL libraries... What am I missing to make it work?

Also, do you get screen blanking with wlr-randr? I just get failed to connect to display and if I run as root XDG_RUNTIME_DIR is invalid or not set in the environment If I run setterm from a keyboard on the RPi then it will blank and wake up but it doesn't work either on the remote picframe.

helgeerbe commented 1 year ago

@paddywwoof which image are you using?. I used

Raspberry Pi OS with desktop

Release date: October 10th 2023 System: 64-bit Kernel version: 6.1 Debian version: 12 (bookworm) Size: 1,093MB

wlr-randr does not work remotely (ssh) and wayfinder (compositor) has to be running. To test ist run it from a terminal on the desktop:

wlr-randr --output HDMI-A-1 --off; sleep 10; wlr-randr --output HDMI-A-1 --on
paddywwoof commented 1 year ago

I am using 2023-10-10-raspios-bookworm-armhf-lite 32 bit... but the first SD I burned was the desktop version and I think I had the same error messages when I tried to pip install numpy in a venv. (I've now over written that SD with the new lite version!)

I was running wlr-randr in a python subprocess.run() on the picframe RPi but I hadn't got the wayfinder compositor running (is that right or should it be wayfire, I can't find much info on either on line)

sapnho commented 1 year ago

I also can't get Helge's instructions to work. Using a Pi 4 with Bookworm Desktop (Recommended). Does it work through Terminal? I don't have a keyboard connected to my Pi and it's not really the way people would configure their picture frame.

helgeerbe commented 1 year ago

I assume, that lite is missing too many packages. I would go with desktop, to show that it's working. Using lite we have to identify the missing packages.

Wayfinder must be running. Using wayland, the compositor provides the api. If we are happy, we could replace wafinder with cage. Cage is a compositor for a single kiosk application. But for now, I would use the raspberry standard tools.

@sapnho I don't have a spare pi4. But yes, you should be able to do the configuration through a terminal. Only starting the service through a terminal seems not to work.

Tomorrow I will do a clean set up and will document each step again.

paddywwoof commented 1 year ago

picframe itself runs fine on lite with only libsdl2-dev, python3-sdl2, python3-numpy, python3-pil and the other modules needed by picframe the problem is getting python3-venv working. I did a very basic venv just install numpy and it was impossible to load. Surely that shouldn't happen! Maybe it's a bug in pywheels.org?

helgeerbe commented 1 year ago

Yes it's running. But you are using xWayland (even with sdl). xWayland is a xServer layer in wayland for legacy applications. The future is to get rid of X completely.

I hadn't any issue creating the python virtual environment. So I could just run pip install picframe and all dependencies were installed from pypi.org

paddywwoof commented 1 year ago

Helge, yes you are right. Even on RPi 4 it's using xWayland. It would be nice if SDL could 'automatically' start wayland like it does for X11 but it doesn't seem to, if the SDL_VIDEODRIVER is set to wayland it fails. I think wayfire needs to be started in another process. Somehow!

I can't decide whether using using the pip route for things like numpy, pill and pysdl2 is the best route. I know we've had problems in the past and needed to specify versions current 32 bit armhf lite pip packages seem to be in disarray. Just looking at the piwheels.org website for numpy it says you need to

sudo apt install libgfortran5 libopenblas0-pthread
pip3 install numpy

so why not just sudo apt install python3-numpy instead? There is an option when creating a venv to use --system-site-packages

helgeerbe commented 1 year ago

Hi, I reinstalled picframe on bookworm. Using native Wayland (no X). I created a wiki page, that can be edited more easily:

https://github.com/helgeerbe/picframe/wiki/Setup-guide-Bookworm-and-Wayland

helgeerbe commented 1 year ago

Hi @paddywwoof I could install all dependent packets with a simple pip install picframe. Using a virtual environment we can control even the versions of the packets which are required by picframe.

paddywwoof commented 1 year ago

@helgeerbe that works great. The SD burning and OS loading is significantly more time consuming than the lite versions but that only really matters during testing where I'm doing it lots of times. The average user will just do it once. I'm in the process of merging pi3d sdl2 branch to main but in the mean time I found I could replace switching branches section with

pip uninstall picframe
pip uninstall pi3d
pip install git+https://github.com/tipam/pi3d@sdl2
pip install git+https://github.com/helgeerbe/picframe@sdl2
pip install pysdl2

i.e. it's possible to pip install directly from a git branch, which I didn't realise before!

Now we just need to figure out how to launch wayfire without all the desktop stuff. Thanks again for sorting this out.

Paddy

PS I'm running on RPi 4