Closed EDIflyer closed 2 years ago
The luma.emulator package provides the capture driver. At runtime, the core enumerates which display drivers are present and dynamically constructs that list. The docs (and/or cli help) probably ought to be updated to make that clear
Ahhh! Thanks @rm-hull - I must have twigged that eventually last time I did it then forgot this time! Will submit a PR re the docs.
I installed the emulator which seemed to go OK:
$ sudo -H pip3 install --upgrade luma.emulator
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting luma.emulator
Downloading https://www.piwheels.org/simple/luma-emulator/luma.emulator-1.4.0-py2.py3-none-any.whl (27 kB)
Requirement already satisfied: luma.core>=1.14.0 in /usr/local/lib/python3.9/dist-packages (from luma.emulator) (2.3.1)
Collecting pygame
Downloading https://www.piwheels.org/simple/pygame/pygame-2.1.2-cp39-cp39-linux_armv6l.whl (8.9 MB)
|████████████████████████████████| 8.9 MB 75 kB/s
Requirement already satisfied: pyftdi in /usr/local/lib/python3.9/dist-packages (from luma.core>=1.14.0->luma.emulator) (0.53.3)
Requirement already satisfied: RPI.GPIO in /usr/local/lib/python3.9/dist-packages (from luma.core>=1.14.0->luma.emulator) (0.7.1a4)
Requirement already satisfied: deprecated in /usr/local/lib/python3.9/dist-packages (from luma.core>=1.14.0->luma.emulator) (1.2.13)
Requirement already satisfied: smbus2 in /usr/local/lib/python3.9/dist-packages (from luma.core>=1.14.0->luma.emulator) (0.4.1)
Requirement already satisfied: spidev in /usr/local/lib/python3.9/dist-packages (from luma.core>=1.14.0->luma.emulator) (3.5)
Requirement already satisfied: pillow>=4.0.0 in /usr/local/lib/python3.9/dist-packages (from luma.core>=1.14.0->luma.emulator) (8.4.0)
Requirement already satisfied: cbor2 in /usr/local/lib/python3.9/dist-packages (from luma.core>=1.14.0->luma.emulator) (5.4.2)
Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.9/dist-packages (from deprecated->luma.core>=1.14.0->luma.emulator) (1.13.3)
Requirement already satisfied: pyusb!=1.2.0,>=1.0.0 in /usr/local/lib/python3.9/dist-packages (from pyftdi->luma.core>=1.14.0->luma.emulator) (1.2.1)
Requirement already satisfied: pyserial>=3.0 in /usr/local/lib/python3.9/dist-packages (from pyftdi->luma.core>=1.14.0->luma.emulator) (3.5)
Installing collected packages: pygame, luma.emulator
Successfully installed luma.emulator-1.4.0 pygame-2.1.2
$ python3 -m pip show luma.emulator
Name: luma.emulator
Version: 1.4.0
Summary: A suite of pseudo-devices for luma.core components
Home-page: https://github.com/rm-hull/luma.emulator
Author: Richard Hull
Author-email: richard.hull@destructuring-bind.org
License: MIT
Location: /usr/local/lib/python3.9/dist-packages
Requires: luma.core, pygame
Required-by:
But then when I tried to run it I was still getting a complaint about pygame not being installed?
$ ./demo.py --display capture
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/luma/emulator/device.py", line 43, in __init__
import pygame
File "/usr/local/lib/python3.9/dist-packages/pygame/__init__.py", line 83, in <module>
from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
ImportError: libSDL2-2.0.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/./demo.py", line 99, in <module>
main()
File "/home/pi/./demo.py", line 54, in main
device = get_device()
File "/home/pi/demo_opts.py", line 61, in get_device
device = cmdline.create_device(args)
File "/usr/local/lib/python3.9/dist-packages/luma/core/cmdline.py", line 272, in create_device
device = Device(**vars(args))
File "/usr/local/lib/python3.9/dist-packages/luma/emulator/device.py", line 102, in __init__
super(capture, self).__init__(width, height, rotate, mode, transform, scale)
File "/usr/local/lib/python3.9/dist-packages/luma/emulator/device.py", line 45, in __init__
raise RuntimeError("Emulator requires pygame to be installed")
RuntimeError: Emulator requires pygame to be installed
So I re-ran pygame install separately (although it looks like it was correctly installed before and this just downloaded 2.1.1 in addition to 2.1.2 for some reason??)...
$ sudo -H pip3 install --upgrade pygame
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pygame in /usr/local/lib/python3.9/dist-packages (2.1.2)
Collecting pygame
Using cached https://www.piwheels.org/simple/pygame/pygame-2.1.2-cp39-cp39-linux_armv6l.whl (8.9 MB)
Downloading https://www.piwheels.org/simple/pygame/pygame-2.1.1-cp39-cp39-linux_armv6l.whl (8.9 MB)
|████████████████████████████████| 8.9 MB 52 kB/s
$ python3 -m pip show pygame
Name: pygame
Version: 2.1.2
Summary: Python Game Development
Home-page: https://www.pygame.org
Author: A community project.
Author-email: pygame@pygame.org
License: LGPL
Location: /usr/local/lib/python3.9/dist-packages
Requires:
Required-by: luma.emulator
but I still get the same error of the Emulator requiring pygame to be installed?
PS the dynamically generated list from ./demo.py --help
now lists it at least...
--display DISPLAY, -d DISPLAY
Display type, supports real devices or emulators. Allowed values are:
ssd1306, ssd1309, ssd1322, ssd1362, ssd1322_nhd, ssd1325, ssd1327,
ssd1331, ssd1351, sh1106, ws0010, winstar_weh, capture, gifanim, pygame,
asciiart, asciiblock, linux_framebuffer (default: ssd1306)
are you able to import pygame using that interpreter? python3 -c "import pygame"
shouldn't throw any errors.
Ahh, interesting @thijstriemstra it does indeed throw an error!...
$ python3 -c "import pygame"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.9/dist-packages/pygame/__init__.py", line 83, in <module>
from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
ImportError: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
I tried running sudo -H pip3 install --upgrade --force-reinstall --ignore-installed pygame
but still got the same error after when I tried to import it.
Any thoughts how to resolve? 😬
Did you see the prerequisites here https://luma-emulator.readthedocs.io/en/latest/install.html#system-packages ?
Yes - as far as I could see they were all met? It said 'Requirements already satisfied' for them all? https://github.com/rm-hull/luma.examples/issues/152#issuecomment-1027171558
OK so I uninstalled pygame and luma.emulator and reinstalled them again, this time I got a different error...
$python3 demo.py --display capture
pygame 2.1.2 (SDL 2.0.14, Python 3.9.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/home/pi/demo.py", line 99, in <module>
main()
File "/home/pi/demo.py", line 54, in main
device = get_device()
File "/home/pi/demo_opts.py", line 61, in get_device
device = cmdline.create_device(args)
File "/usr/local/lib/python3.9/dist-packages/luma/core/cmdline.py", line 272, in create_device
device = Device(**vars(args))
File "/usr/local/lib/python3.9/dist-packages/luma/emulator/device.py", line 102, in __init__
super(capture, self).__init__(width, height, rotate, mode, transform, scale)
File "/usr/local/lib/python3.9/dist-packages/luma/emulator/device.py", line 49, in __init__
self._transform = getattr(transformer(pygame, width, height, scale),
File "/usr/local/lib/python3.9/dist-packages/luma/emulator/render.py", line 22, in __init__
[self._pygame.image.load(str(base_dir.joinpath("images", img)))
File "/usr/local/lib/python3.9/dist-packages/luma/emulator/render.py", line 22, in <listcomp>
[self._pygame.image.load(str(base_dir.joinpath("images", img)))
pygame.error: File is not a Windows BMP file
After a bit more Googling I came across this from last year - https://github.com/pygame/pygame/issues/2503
I did sudo apt-get install libsdl2-image-2.0-0
and that seemed to do the trick! So I wonder if the pre-requisites need to be change from libsdl-image1.2-dev
to libsdl2-image-2.0-0
?
(I'm using Raspberry Pi OS bullseye in case that makes any difference)
Anyway, thanks to your both for your help (not to mention creating this excellent library in the first place!) - I've now got PNGs generating so can enhance my user guide!
So I wonder if the pre-requisites need to be change from libsdl-image1.2-dev to libsdl2-image-2.0-0?
quite probably
OK have done a PR for that - thanks again @rm-hull and @thijstriemstra - greatly appreciate the rapid help! 👍🥳
I've downloaded the latest version of the examples from this repository, they run fine on my ssd1306 screen However when I try to output to PNG files using the capture option (
~/examples $ ./demo.py --display capture
) I get the following error:I note that help shows the following:
whereas the README.md for here shows quite a different list:
luma.core version info as follows:
luma.oled version info as follows:
The bit that's esp frustrating is I managed to get it to work a month or so ago on a different unit and I can't work out why it's not wanting to work here! Thanks in advance for any help/advice!