Unable to instantiate generator (again)

71 views
Skip to first unread message

Lucas Heijst

unread,
May 29, 2023, 8:56:24 AM5/29/23
to weewx-development
Started with a fresh install of debian buster light on my rpi model 2
Followed by a fresh install of weewx via:
pip3 install weewx --user
/root/.local/bin/weectl station create --no-prompt

I got the following error:
Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/weewx/reportengine.py", line 179, in run
    obj = weeutil.weeutil.get_object(generator)(
  File "/root/.local/lib/python3.7/site-packages/weeutil/weeutil.py", line 1352, in get_object
    mod = __import__(module)
  File "/root/.local/lib/python3.7/site-packages/weewx/imagegenerator.py", line 14, in <module>
    import weeplot.genplot
  File "/root/.local/lib/python3.7/site-packages/weeplot/genplot.py", line 13, in <module>
    from PIL import Image, ImageDraw, ImageFont
  File "/root/.local/lib/python3.7/site-packages/PIL/Image.py", line 103, in <module>
    from . import _imaging as core
ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory

pip3 install weewx --upgrade reports:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already up-to-date: weewx in /root/.local/lib/python3.7/site-packages (5.0.0b3)
Requirement already satisfied, skipping upgrade: configobj<6.0,>=5.0 in /root/.local/lib/python3.7/site-packages (from weewx) (5.0.8)
Requirement already satisfied, skipping upgrade: Pillow>=5.2 in /root/.local/lib/python3.7/site-packages (from weewx) (9.5.0)
Requirement already satisfied, skipping upgrade: pyusb<2.0.0,>=1.0.2 in /root/.local/lib/python3.7/site-packages (from weewx) (1.2.1)
Requirement already satisfied, skipping upgrade: ephem<5.0,>=4.1 in /root/.local/lib/python3.7/site-packages (from weewx) (4.1.4)
Requirement already satisfied, skipping upgrade: six<2,>=1 in /usr/lib/python3/dist-packages (from weewx) (1.12.0)
Requirement already satisfied, skipping upgrade: pyserial<4.0,>=3.4 in /root/.local/lib/python3.7/site-packages (from weewx) (3.5)
Requirement already satisfied, skipping upgrade: PyMySQL[rsa]<2.0,>=1.0 in /root/.local/lib/python3.7/site-packages (from weewx) (1.0.3)
Requirement already satisfied, skipping upgrade: CT3<4.0,>=3.1 in /root/.local/lib/python3.7/site-packages (from weewx) (3.3.1)
Requirement already satisfied, skipping upgrade: cryptography; extra == "rsa" in /usr/lib/python3/dist-packages (from PyMySQL[rsa]<2.0,>=1.0->weewx) (2.6.1)

Tom, 
on feb 21, 2023 you wrote:
-----
Well, shoot. Now I remember why I required Pillow >=8.2. You get a mysterious segfault with earlier versions. The problem was fixed in Pillow 8.2.

See https://github.com/python-pillow/Pillow/issues/3066

However, there is a workaround, provided no one is trying to use a font that requires a vertical layout. I think we're safe there. v5.0.0a20 uses the workaround.
-----

The current version of Pillow  meets the condition >= 8.2 however:
pip3 show Pillow
Name: Pillow
Version: 9.5.0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Jeffrey A. Clark (Alex)
Author-email: acl...@aclark.net
License: HPND
Location: /root/.local/lib/python3.7/site-packages
Requires:
Required-by: weewx

So, what's wrong this time?

Tom Keffer

unread,
May 29, 2023, 9:03:49 AM5/29/23
to Lucas Heijst, weewx-development
I would guess that you're missing the underlying JPEG library

sudo apt install libopenjp2-7

-tk


--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/67d36316-aef8-4230-9df4-da2bd9acfad8n%40googlegroups.com.

Lucas Heijst

unread,
May 29, 2023, 9:19:26 AM5/29/23
to weewx-development

You guessed right, Tom, installing libopenjp2-7 solved the problem.

Question: why was this module not installed by the weewx install?
Op maandag 29 mei 2023 om 10:03:49 UTC-3 schreef Tom Keffer:

Tom Keffer

unread,
May 29, 2023, 9:39:40 AM5/29/23
to Lucas Heijst, weewx-development
It's a good question, and I'm not sure I know the full answer.

Generally, if one installs Pillow, it installs by using a wheel, which includes the necessary binary files (look in ~/.local/lib/python3.7/site-packages/Pillow.libs). However, if a wheel is not available for your platform (and it may not be for buster light), then pip will compile from source. That requires that the underlying libraries, including openjpeg, have already been installed.

That's my best guess.

-tk

Lucas Heijst

unread,
May 29, 2023, 9:58:44 AM5/29/23
to weewx-development
Thanks for your answer Tom

I skipped the step "pip3 install wheel" because I thought this was not needed anymore

sudo apt update
sudo apt -y install gcc python3-dev python3-pip
(skipped step: pip3 install wheel)
pip3 install weewx --user

Op maandag 29 mei 2023 om 10:39:40 UTC-3 schreef Tom Keffer:
Message has been deleted
Message has been deleted

Tom Keffer

unread,
Mar 20, 2024, 8:50:38 AMMar 20
to Vince Skahan, weewx-development
Since I responded to Luke, I have a much better understanding of how this happens. See the section on Pillow in the wiki article pip troubleshooting.

On Wed, Mar 20, 2024 at 5:08 AM Vince Skahan <vince...@gmail.com> wrote:
Tom - this is an old thread but I thought I'd mention that I just ran into this on a clean 5.0.2 pip installation on a couple newly imaged pi running the latest 32-bit raspi os dated march-15-2024.   Same error happens on a pi4 and pi5 running that os.

2024-03-19T15:25:16.177588-07:00 pi5 weewxd[3821]: ERROR weewx.reportengine: Unable to instantiate generator 'weewx.imagegenerator.ImageGenerator'
2024-03-19T15:25:16.177710-07:00 pi5 weewxd[3821]: ERROR weewx.reportengine:         ****  libopenjp2.so.7: cannot open shared object file: No such file or directory

Running "sudo apt install -y libopenjp2-7" as per the thread above fixes the problem still with current raspios.  Cool.

To quantify the os setup,  "dpkg --print-architecture" reports armhf on the pi5 which reflects what the kernel is really doing.  The 'arch' command returns a bogus aarch64 result when running the raspios 32-bit os, which is a known though confusing thing.

Reply all
Reply to author
Forward
0 new messages