felddy / weewx-docker

Docker container for WeeWx weather station server
https://hub.docker.com/r/felddy/weewx
Creative Commons Zero v1.0 Universal
59 stars 39 forks source link

ERROR weewx.reportengine: **** No module named 'Cheetah', ... (and 'Images' and Rsync) #18

Closed ghost closed 1 year ago

ghost commented 4 years ago

🐛 Bug Report

Running latest Raspberry Pi OS and Docker. Utilized template docker-compose.yml with minor tweaks for my environment. weewx runs fine pulling data from my IP based David Vantage Pro 2. Submissions to Wunderground and other providers operating as expected. Web Page generation fails due to missing Cheetah and Images modules. Further, Rsync also appears to be missing from image.

My compose looks as follows:

version: "2.3"
services:
  weewx:
    container_name: weewx
    image: felddy/weewx
    network_mode: host
    environment:
      - TIMEZONE=US/Eastern
      - WEEWX_UID=weewx
      - WEEWX_GID=weewx
    volumes:
      - /srv/dev-disk-by-label-dune/Configs/weewx:/data
    restart: always

Variance from template compose file is due to using Portainer v2.0 on Rpi, which is limited to v2.x composer format. I've been unable to utilize the "init: true" as it is unsupported and alternatives do not seem to work either. Unsure if this prevents some internal process your created to install these services, but was unable to locate any references to installing the services post deployment.

Very appreciative for your efforts as one of the few (only?) armhf builds; other main images are 64bit. Here's a broader snapshot of error log:

Sep 11 08:46:18 weewx[17] INFO weewx.manager: Added record 2020-09-11 08:46:00 EDT (1599828360) to database 'weewx.sdb',
Sep 11 08:46:18 weewx[17] INFO weewx.manager: Added record 2020-09-11 08:46:00 EDT (1599828360) to daily summary in 'weewx.sdb',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine: Unable to instantiate generator 'weewx.cheetahgenerator.CheetahGenerator',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  No module named 'Cheetah',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  Traceback (most recent call last):,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 180, in run,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      obj = weeutil.weeutil.get_object(generator)(,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weeutil/weeutil.py", line 1093, in get_object,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      mod = __import__(module),
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weewx/cheetahgenerator.py", line 66, in <module>,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      import Cheetah.Filters,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  ModuleNotFoundError: No module named 'Cheetah',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  Generator ignored,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine: Unable to instantiate generator 'weewx.imagegenerator.ImageGenerator',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  No module named 'Image',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  Traceback (most recent call last):,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weeplot/genplot.py", line 15, in <module>,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      from PIL import Image, ImageDraw,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  ModuleNotFoundError: No module named 'PIL',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  ,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  During handling of the above exception, another exception occurred:,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  ,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  Traceback (most recent call last):,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 180, in run,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      obj = weeutil.weeutil.get_object(generator)(,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weeutil/weeutil.py", line 1093, in get_object,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      mod = __import__(module),
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weewx/imagegenerator.py", line 19, in <module>,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      import weeplot.genplot,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weeplot/genplot.py", line 17, in <module>,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****      import Image, ImageDraw,
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  ModuleNotFoundError: No module named 'Image',
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine:         ****  Generator ignored,
Sep 11 08:46:19 weewx[17] INFO weewx.reportengine: Copied 0 files to /data/www,
Sep 11 08:46:19 weewx[17] ERROR weeutil.rsyncupload: rsync does not appear to be installed on this system. (errno 2, 'No such file or directory'),
Sep 11 08:46:19 weewx[17] ERROR weewx.reportengine: rsyncgenerator: Caught exception '<class 'FileNotFoundError'>': [Errno 2] No such file or directory: 'rsync',
Sep 11 08:46:19 weewx[17] INFO weewx.restx: PWSWeather: Published record 2020-09-11 08:46:00 EDT (1599828360),
Sep 11 08:46:20 weewx[17] INFO weewx.restx: Wunderground-RF: Published record 2020-09-11 08:46:20 EDT (1599828380),
Sep 11 08:46:20 weewx[17] INFO weewx.restx: Wunderground-RF: Published record 2020-09-11 08:46:20 EDT (1599828380),
D37R4C7 commented 4 years ago

I do have the same issue, running a normal Linux installation.

D37R4C7 commented 4 years ago

I needed to install Cheetah3 within the image manually to get it working. Maybe this is because you changed from python alpine to slim?

ThomDietrich commented 3 years ago

Hey @felddy and others, did you ever solve this? I've just spent a few minutes on this but wasn't able to get it working with the multi-stage approach.

ThomDietrich commented 3 years ago

The following diff represents what I ended up with. It's not a satisfying solution but maybe it helps others while we figure out how to solve this is a better way :) Best!

diff --git a/Dockerfile b/Dockerfile
index b61a104..526132f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,13 +2,14 @@ FROM python:3-alpine as stage-1

 ARG WEEWX_UID=421
 ENV WEEWX_HOME="/home/weewx"
-ENV WEEWX_VERSION="4.4.0"
+ENV WEEWX_VERSION="4.5.1"
 ENV ARCHIVE="weewx-${WEEWX_VERSION}.tar.gz"

 RUN addgroup --system --gid ${WEEWX_UID} weewx \
   && adduser --system --uid ${WEEWX_UID} --ingroup weewx weewx

 RUN apk --no-cache add tar
+#RUN apk --no-cache add py3-pillow zlib-dev jpeg-dev build-base

 WORKDIR /tmp
 COPY src/hashes requirements.txt ./
@@ -26,6 +27,7 @@ RUN chown -R weewx:weewx ${WEEWX_HOME}
 # Python setup
 RUN python -m venv /opt/venv
 ENV PATH="/opt/venv/bin:$PATH"
+RUN pip install --no-cache wheel
 RUN pip install --no-cache --requirement requirements.txt

 WORKDIR ${WEEWX_HOME}
@@ -34,12 +36,17 @@ RUN bin/wee_extension --install /tmp/weewx-mqtt.zip
 RUN bin/wee_extension --install /tmp/weewx-interceptor.zip
 COPY src/entrypoint.sh src/version.txt ./

-FROM python:3-slim as stage-2
+FROM python:3 as stage-2

 ARG TARGETPLATFORM
 ARG WEEWX_UID=421
 ENV WEEWX_HOME="/home/weewx"
-ENV WEEWX_VERSION="4.4.0"
+ENV WEEWX_VERSION="4.5.1"

 # For a list of pre-defined annotation keys and value types see:
 # https://github.com/opencontainers/image-spec/blob/master/annotations.md
@@ -55,9 +62,15 @@ RUN apt-get update && apt-get install -y libusb-1.0-0 gosu busybox-syslogd tzdat

 WORKDIR ${WEEWX_HOME}

-COPY --from=stage-1 /opt/venv /opt/venv
+#COPY --from=stage-1 /opt/venv /opt/venv
 COPY --from=stage-1 ${WEEWX_HOME} ${WEEWX_HOME}

+RUN pip install --no-cache wheel setuptools
+RUN pip install --no-cache configobj paho-mqtt pyserial pyusb
+RUN pip install --no-cache Cheetah3
+RUN pip install --no-cache Pillow
+
 RUN mkdir /data && \
     cp weewx.conf /data

diff --git a/src/hashes b/src/hashes
index 69e40eb..2945e6d 100644
--- a/src/hashes
+++ b/src/hashes
@@ -1,3 +1,3 @@
-4ad1f8ff990ce86d80b3bc5448d5545e67e8b42ac14fc6a041b7734740e846c5  weewx-4.4.0.tar.gz
+9650f9a4ce0f300a652d926820bc5b683a1826fd668c0e71413e88c772d7f056  weewx-4.5.1.tar.gz
 9580cc3e3d617d20ffc42138712634850f37716a1257e9da0516407970765813  weewx-mqtt.zip
 6229d493acd051730530ab50c235f57cc7f9c53dc1a8060c7b6e4817dd2bf66d  weewx-interceptor.zip
reba0 commented 3 years ago

I have this issue also. Could you please let me know how I can resolve it. Many thanks Thanks for the smiley. Would be nice if you could help me

garberw commented 2 years ago

I have this issue too. fedora 35.

nickbp commented 2 years ago

A possible solution is using felddy/weewx as a base for your own image where the dependencies/libraries you need have been preinstalled. Here is an example that I'm using where I wanted mysql support, html report support, and the weewx-weatherlink-live driver. This formula has worked for me and may solve the issues that others have seen around missing python libraries.

FWIW I think it'd make sense to "upstream" some of this into the main felddy/weewx image - for example it probably wouldn't hurt to include the mysql support and common HTML rendering libraries "out of the box".

Quick explanation of what's going on in the below steps:

FROM docker.io/library/debian:bullseye-slim

# weewx image doesn't have curl/wget so just download from separate stage
ENV EXTENSION_VERSION=v1.0.11
RUN apt-get update \
  && apt-get install -y curl \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists /var/cache/apt/archives \
  && curl \
  -Lo /tmp/weewx-weatherlink-live.tar.xz \
  https://github.com/michael-slx/weewx-weatherlink-live/releases/download/${EXTENSION_VERSION}/weewx-weatherlink-live-${EXTENSION_VERSION}.tar.xz

FROM docker.io/felddy/weewx:4.5.1

COPY --from=0 /tmp/weewx-weatherlink-live.tar.xz /tmp/weewx-weatherlink-live.tar.xz
# - install prerequisites for running pip install
# - install needed python packages to venv via pip (apt-get installs to host)
#   note that CD TO SITE-PACKAGES IS REQUIRED because pip just installs to cwd for some reason
# - uninstall gcc after completing pip install
# - install weatherlink-live extension
RUN apt-get update \
  && apt-get install -y gcc libmariadb-dev-compat \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists /var/cache/apt/archives \
  && which pip \
  && cd /opt/venv/lib/python3.10/site-packages/ \
  && /opt/venv/bin/pip install --no-cache-dir mysqlclient requests Cheetah3 Pillow \
  && apt-get remove --purge -y gcc \
  && apt-get autoremove --purge -y \
  && /opt/venv/bin/python -c 'import MySQLdb, requests, Cheetah, PIL.Image' \
  && ${WEEWX_HOME}/bin/wee_extension --install /tmp/weewx-weatherlink-live.tar.xz \
  && rm -v /tmp/weewx-weatherlink-live.tar.xz

In any case, it should be possible to take the above steps as an example and update them to install what you need (while removing the stuff you don't need). In this case the resulting image ends up being around 90MB vs around 65MB for the original, so not too bad.

Also, if anyone happens to find this because they are running weewx-weatherlink-live in a Docker image, note that you need the container on the same subnet as the WeatherLink Live in order for UDP broadcasts to work and reports to be generated. This can be accomplished by running the container with --network=host/hostNetwork: true.

marcusds commented 2 years ago

To confirm, to get my reports generating I had to run pip install Cheetah3 pillow in the container.

ThomDietrich commented 2 years ago

@felddy did you consider releasing a new image with these changes?

Edit: Seems you did. Can anyone confirm whether the issue here is fixed?

felddy commented 2 years ago

I'm sorry. I've totally neglected this issue. I'm catching up on this repo's PRs and issues now. I'll chime in on this after I have a chance to digest it.

bit4gam commented 2 years ago

I'm sorry. I've totally neglected this issue. I'm catching up on this repo's PRs and issues now. I'll chime in on this after I have a chance to digest it.

@felddy sorry but if that modules are missing and the Docker Hub Image is not working, why you are still releasing it on docker hub?

alexoconner commented 1 year ago

@felddy was this ever resolved? I can see you made a lot of updates to the repo. But it seems its still not generating the html reports for me with the same error described in this issue. I also opened this discussion before I realised it might be related to this: https://github.com/felddy/weewx-docker/discussions/210

Edit: looks like this PR is still pending approval https://github.com/felddy/weewx-docker/pull/88 - that would do it I guess?

jonathankoren commented 1 year ago

Not only has this not been resolved, but #88 is so out of date, that the file that the patch was applied to no longer exists.

At this point, this project looks like abandonware.

Shame. It almost works. Someone with more time and than me could probably get it back up and running, or maybe get a working Docker working.

ThomDietrich commented 1 year ago

Hello @felddy, are you still eager to maintain this project? If not, I want to propose to create a successor fork over at https://github.com/rejuvenate - We aim to provide a place for projects maintained by multiple active community members.

If everyone agrees I will create the fork over the next couple of days. @jonathankoren, @nickbp, all others and @felddy: Who would like to be added as maintainer to the project?

felddy commented 1 year ago

Hello @felddy, are you still eager to maintain this project? If not, I want to propose to create a successor fork over at https://github.com/rejuvenate - We aim to provide a place for projects maintained by multiple active community members.

If everyone agrees I will create the fork over the next couple of days. @jonathankoren, @nickbp, all others and @felddy: Who would like to be added as maintainer to the project?

This project is licensed CC0. You have the freedom to do anything you'd like with the code. I do not need to be a maintainer on any forks, but I appreciate the offer.

I apologize for not being more attentive to this feature. I have a hard time telling people "No". That said, I don't think it is a good fit for this repo. There is a slippery slope to installing "all the things" and then having to test and support them forever. As you have pointed out, it is easy enough to fork and extend the container.

In the future I'll port over the CONTAINER_PATCHES functionality that I implemented in my FoundryVTT container. This has proven to be a useful way for users to add a-la-cart functionality and extensions to the container, and a good alternative to creating a new image for those without Docker skills.

At that time I'll remove default extensions like interceptor or mqtt and document how to configure them at container startup.

Thank you all for contributing.

windseye commented 12 months ago

Cross posted from #88

I was able to manually add pillow and cheetah to my running container as follows:

With weewx container running docker exec -it -u 0 weewx bash pip install Pillow==9.4.0 pip install CT3

restart weewx container

Ubuntu 22.04

The html files are now properly generated.

It would be nice to have them added to the image but I do not have the knowledge to do that.

ThomDietrich commented 12 months ago

Thanks @felddy for your explanation. It's great to see you active and I respect your opinion.

I will release a docker image that is based on the one here, but add the most obvious extensions, including interceptor, mqtt, or Pillowwith some useful additions. I already have it configured locally.