sighmon / balena-enviro-plus

Enviro-plus environment sensor deployment to Raspberry Pi via Balena IoT platform
9 stars 7 forks source link

Unable to get the Docker Image to run #12

Open jozujo opened 3 years ago

jozujo commented 3 years ago

Hi, I'm very much a beginner to programming and running a headless Pi Zero, so please forgive me if there is something obvious that I have missed, but I've been having a few problems getting this project to run and wondered if anyone could help.

The first problem (which I think I found a workaround for) is that after following the first couple of steps, when I try to build the Docker image using docker build -t sighmon/enviroplus_exporter:v1 ., I get the following error:

Sending build context to Docker daemon  2.146MB
Step 1/25 : FROM sighmon/balena-enviro-plus:v1
 ---> 6c1b56c59a84
Step 2/25 : WORKDIR /usr/src
 ---> Using cache
 ---> 32084b60b331
Step 3/25 : RUN sudo pip3 install --upgrade setuptools && sudo pip3 install     adafruit-circuitpython-lc709203f     influxdb-client     prometheus_client     python-periphery     SafecastPy
 ---> Using cache
 ---> 3fe3ddf2c904
Step 4/25 : COPY enviroplus_exporter/enviroplus_exporter.py enviroplus_exporter.py
 ---> b35f73bf4d03
Step 5/25 : COPY enviroplus_exporter/notecard/notecard/notecard.py notecard/notecard/notecard.py
COPY failed: file not found in build context or excluded by .dockerignore: stat enviroplus_exporter/notecard/notecard/notecard.py: file does not exist

To get around this, I have cloned the directory from the original repo as follows (having navigated to pi@raspberrypi:~/balena-enviro-plus/enviroplus_exporter/notecard first): git clone https://github.com/blues/note-python.git

And then moving the files up into the correct filepath.

This seems to allow the Docker Image to build successfully:

Sending build context to Docker daemon   2.82MB
Step 1/25 : FROM sighmon/balena-enviro-plus:v1
 ---> 6c1b56c59a84
Step 2/25 : WORKDIR /usr/src
 ---> Using cache
 ---> 32084b60b331
Step 3/25 : RUN sudo pip3 install --upgrade setuptools && sudo pip3 install     adafruit-circuitpython-lc709203f     influxdb-client     prometheus_client     python-periphery     SafecastPy
 ---> Using cache
 ---> 3fe3ddf2c904
Step 4/25 : COPY enviroplus_exporter/enviroplus_exporter.py enviroplus_exporter.py
 ---> Using cache
 ---> b35f73bf4d03
Step 5/25 : COPY enviroplus_exporter/notecard/notecard/notecard.py notecard/notecard/notecard.py
 ---> 22276a85dde1
Step 6/25 : ENV INFLUXDB_URL="https://location.gcp.cloud2.influxdata.com"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 574418c8438a
Removing intermediate container 574418c8438a
 ---> 7834ae3ed782
Step 7/25 : ENV INFLUXDB_TOKEN="your_token"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in f498816d855b
Removing intermediate container f498816d855b
 ---> 0c4e417fcf81
Step 8/25 : ENV INFLUXDB_ORG_ID="your_organisation_id"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 329a770aa92c
Removing intermediate container 329a770aa92c
 ---> a4c520326567
Step 9/25 : ENV INFLUXDB_BUCKET="your_bucket_name"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 2ed1f62919d0
Removing intermediate container 2ed1f62919d0
 ---> 30080e1f0819
Step 10/25 : ENV INFLUXDB_SENSOR_LOCATION="your_sensor_location"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 08593262b803
Removing intermediate container 08593262b803
 ---> b909a26388d6
Step 11/25 : ENV INFLUXDB_TIME_BETWEEN_POSTS="number_of_seconds_between_posts"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in d2731fa9bae5
Removing intermediate container d2731fa9bae5
 ---> caf56ea83701
Step 12/25 : ENV LUFTDATEN_TIME_BETWEEN_POSTS="30"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in eea90f08d7af
Removing intermediate container eea90f08d7af
 ---> 4681a6eb4059
Step 13/25 : ENV SAFECAST_TIME_BETWEEN_POSTS="300"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in b6b7beeab5d1
Removing intermediate container b6b7beeab5d1
 ---> f3e11b8b916a
Step 14/25 : ENV SAFECAST_DEV_MODE="false"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in f5dc91b63f1f
Removing intermediate container f5dc91b63f1f
 ---> b0487fa12e2d
Step 15/25 : ENV SAFECAST_API_KEY="your_api_key"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in a6ba486508e5
Removing intermediate container a6ba486508e5
 ---> fd79042a4cb6
Step 16/25 : ENV SAFECAST_API_KEY_DEV="your_dev_api_key"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 6b900181bb49
Removing intermediate container 6b900181bb49
 ---> 1491fdde2c83
Step 17/25 : ENV SAFECAST_LATITUDE="your_sensor_latitude"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 05c5862c3cf8
Removing intermediate container 05c5862c3cf8
 ---> efe6fb684e2e
Step 18/25 : ENV SAFECAST_LONGITUDE="your_sensor_longitude"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 44a3c975f12a
Removing intermediate container 44a3c975f12a
 ---> 9985f3619869
Step 19/25 : ENV SAFECAST_DEVICE_ID="226"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in d3c306fc9324
Removing intermediate container d3c306fc9324
 ---> 6332f13ed15d
Step 20/25 : ENV SAFECAST_LOCATION_NAME="your_sensor_location"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in ecfcd7ecf999
Removing intermediate container ecfcd7ecf999
 ---> fd1f6a8dfa24
Step 21/25 : ENV NOTECARD_TIME_BETWEEN_POSTS="600"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 12e005c432f9
Removing intermediate container 12e005c432f9
 ---> 111c7bb4a9dd
Step 22/25 : ENV DEBUG="true"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 7f5ab055b6f4
Removing intermediate container 7f5ab055b6f4
 ---> 096c344fabd7
Step 23/25 : ENV TEMPERATURE_COMPENSATION="6.6"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 40f5057ae344
Removing intermediate container 40f5057ae344
 ---> 698b2f782462
Step 24/25 : ENV HUMIDITY_COMPENSATION="24.7"
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in 967ae9546d8e
Removing intermediate container 967ae9546d8e
 ---> ce34733c15d3
Step 25/25 : CMD ["sh", "-c", "modprobe i2c-dev && python3 enviroplus_exporter.py --temp $TEMPERATURE_COMPENSATION --humid $HUMIDITY_COMPENSATION --influxdb true --luftdaten true"]
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
 ---> Running in caa549ea13ea
Removing intermediate container caa549ea13ea
 ---> 7a91668b51fa
Successfully built 7a91668b51fa
Successfully tagged sighmon/enviroplus_exporter:v1

The next problem is, though, that after running docker run -d --privileged -p 8000:8000 sighmon/enviroplus_exporter:v1, I get the readout below and when I try to check the result on raspberrypi.local:8000 (and through the pi's local IP:8000), no page exists.

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
44d1d31bd9aefb9316435c75acea29864d1a00772baac729f18db0d88ee786a3

Running docker ps also only brings up the headers with no further information as below:

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

I assume that once I have been able to get the Dockerfile to run, I should be entering my influxDB credentials, etc. into it, but I'm a bit stuck on how to proceed at the moment, so any ideas as to what I can do to solve this would be greatly appreciated. (Simple instructions that I can copy and paste into the terminal would be especially helpful!) Thanks!

sighmon commented 3 years ago

@jozujo Ah right, sounds like I might have missed a step from the instructions to pull the notecard submodule.

Could you try deleting the note-python folder, and then:

Hopefully that'll pull in the right Notecard code. If it doesn't you could also try: git submodule update --remote whilst in the enviroplus_exporter folder.

Then you should be ready to build again with: docker build -t sighmon/enviroplus_exporter:v1 .

Once you've got your InfluxDB credentials in the Dockerfile, you should start seeing data posted there. Let me know how you get along.

jozujo commented 3 years ago

@sighmon Thanks for the clarification - thanks to your instructions, I was able to pull the Notecard code in, but I still haven't found any luck with actually getting the Dockerfile to run. When I build the file (having entered my InfluxDB credentials in the Dockerfile), after completing all the steps, I get:

Successfully built 2b823acfd5f5
Successfully tagged sighmon/enviroplus_exporter:v1

But then when I try to run docker run -d --privileged -p 8000:8000 sighmon/enviroplus_exporter:v1, I get:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
453794ea230ebfa3c02cdeee5650f688c81de6c6f950703f2146a0a5c4d9bcfe

Again, nothing seems to show up on the PI's IP address at port 8000, and when trying to check to see if the container is running, I get the same empty list.

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

I feel like there might be something very obvious I'm missing, but I'm not sure what it is. Any ideas?

sighmon commented 3 years ago

@jozujo Ah I see - my interim container is linux/amd64, and I'm not seeing that issue because Balena must be doing the handiwork to make it compatible.

Think you might need to try building your own base image and pushing to Docker hub following the instructions: https://github.com/sighmon/balena-enviro-plus#build-your-own-base-image

And then in your Dockerfile, change it to your image on your Docker Hub.

jozujo commented 3 years ago

@sighmon I see. I tried to build my own base image using the instructions you provided. Then, while still in /balena-enviro-plus/base_image, I ran docker run -d --privileged -p 8000:8000 jozujo/balena-enviro-plus:v1, having changed the image in the Dockerfile to jozujo/balena-enviro-plus:v1, but it still came up with the same error as before.

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
524d4b737914e006bd1a5baccc2c5e6d29da48d2505e7dd321af0a1dcd14081c

Other than setting the username and name of the repository on my Docker Hub, I didn't do anything else, but the OS/Arch seems to be set as linux/amd64, rather than linux/arm/v6 which I'm assuming it will need to be. Sorry for all the back and forth on this.

sighmon commented 3 years ago

@jozujo Think you're getting close! After building the base image, move back into the root and re-build the enviroplus_exporter image again. Then you should be able to run it with the command you used above. So the complete steps would be:

jozujo commented 3 years ago

@sighmon You're so optimistic! I'm afraid I still have not had any luck...

pi@raspberrypi:~/balena-enviro-plus $ cd base_image
pi@raspberrypi:~/balena-enviro-plus/base_image $ docker build -t jozujo/balena-enviro-plus:v1 .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM balenalib/raspberry-pi-debian-python:3.7.4-build
 ---> 4dcde83c7d05
Step 2/4 : WORKDIR /usr/src
 ---> Using cache
 ---> 98631984b146
Step 3/4 : RUN pip3 install enviroplus   requests   spidev   RPi.GPIO
 ---> Using cache
 ---> 62b9db8e3483
Step 4/4 : RUN install_packages   python3-smbus   python3-pil   libatlas-base-dev   python3-dev   python3-setuptools   python3-numpy
 ---> Using cache
 ---> 94d348f7d4eb
Successfully built 94d348f7d4eb
Successfully tagged jozujo/balena-enviro-plus:v1
pi@raspberrypi:~/balena-enviro-plus/base_image $ cd ..
pi@raspberrypi:~/balena-enviro-plus $ sudo nano Dockerfile
pi@raspberrypi:~/balena-enviro-plus $ docker build -t jozujo/enviroplus_exporter:v1 .
Sending build context to Docker daemon  2.747MB
Step 1/16 : FROM jozujo/balena-enviro-plus:v1
 ---> 94d348f7d4eb
Step 2/16 : WORKDIR /usr/src
 ---> Using cache
 ---> 75d593c396d6
Step 3/16 : RUN sudo pip3 install --upgrade setuptools && sudo pip3 install     adafruit-circuitpython-lc709203f     influxdb-client     prometheus_client     python-periphery     SafecastPy
 ---> Using cache
 ---> 52a0fac99981
Step 4/16 : COPY enviroplus_exporter/enviroplus_exporter.py enviroplus_exporter.py
 ---> Using cache
 ---> c4e252a225e1
Step 5/16 : COPY enviroplus_exporter/notecard/notecard/notecard.py notecard/notecard/notecard.py
 ---> Using cache
 ---> 6ffe781acd09
Step 6/16 : ENV INFLUXDB_URL="https://ap-southeast-2-1.aws.cloud2.influxdata.com"
 ---> Using cache
 ---> 9cea9a5a69ea
Step 7/16 : ENV INFLUXDB_TOKEN="[REDACTED]"
 ---> Using cache
 ---> 43e022fa66df
Step 8/16 : ENV INFLUXDB_ORG_ID="[REDACTED]"
 ---> Using cache
 ---> 042dbe87c3cb
Step 9/16 : ENV INFLUXDB_BUCKET="[REDACTED]"
 ---> Using cache
 ---> 41456301a877
Step 10/16 : ENV INFLUXDB_SENSOR_LOCATION="[REDACTED]"
 ---> Using cache
 ---> be0314daacd4
Step 11/16 : ENV INFLUXDB_TIME_BETWEEN_POSTS="300"
 ---> Using cache
 ---> bf7114fcd90c
Step 12/16 : ENV LUFTDATEN_TIME_BETWEEN_POSTS="30"
 ---> Using cache
 ---> 274654c95e6d
Step 13/16 : ENV DEBUG="true"
 ---> Using cache
 ---> e1afb037e638
Step 14/16 : ENV TEMPERATURE_COMPENSATION="6.6"
 ---> Using cache
 ---> c89faa7cad4d
Step 15/16 : ENV HUMIDITY_COMPENSATION="24.7"
 ---> Using cache
 ---> 7d82591c5887
Step 16/16 : CMD ["sh", "-c", "modprobe i2c-dev && python3 enviroplus_exporter.py --temp $TEMPERATURE_COMPENSATION --humid $HUMIDITY_COMPENSATION --influxdb true --luftdaten true"]
 ---> Using cache
 ---> 67f743e48cc5
Successfully built 67f743e48cc5
Successfully tagged jozujo/enviroplus_exporter:v1
pi@raspberrypi:~/balena-enviro-plus $ docker run -d --privileged -p 8000:8000 jozujo/enviroplus_exporter:v1
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
dc8f44952d530c7c423ce89cfc83f5e2d2cef112f5936d71084f327cf9e8b261

As usual, trying to access the Pi's IP address at port 8000 nothing shows up, and when trying to check to see if the container is running, I get the same empty list as before.

pi@raspberrypi:~/balena-enviro-plus $ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
pi@raspberrypi:~/balena-enviro-plus $ 
asdfng commented 3 years ago

Hello, I'm a beginner with the same issue. I've been following along, trying a few things to get a better understanding of the issue. I tried running the docker container without the -d and got the following errors:

modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() cound not open moddep file '/lib/modules/5.10.52+/modules.dep.bin'
modprobe: FATAL: Module i2c-dev not found in directory /lib/modules/5.10.52+

I'm not that sure on the difference between running it with or without -d so I could be missing the mark completely, but would this have anything to do with the container exiting immediately after running?

I ran docker ps -a and it seems like the container was started but the status was listed as exited. This leads me to think it's starting and then exiting but I'm unfamiliar with a lot of this so I wouldn't know for sure.

If there's any terminology I'm using improperly please let me know.

sighmon commented 3 years ago

@jozujo Could you please try changing the base image Dockerfile line to be: FROM balenalib/raspberry-pi-debian-python:3.7-build

It may be that Balena removed the arm based 3.7.4 build image.

Also, run it without the -d flag so it's not run in the background... you might see more error messages.

sighmon commented 3 years ago

@asdfng I think your problem might be different - have you enabled I2C in the Raspberry Pi config menu?

asdfng commented 3 years ago

@sighmon I2C is enabled

jozujo commented 3 years ago

Hi @sighmon - thanks for your patience. I did as you mentioned, and I think we're getting closer to the root of the problem, but it doesn't seem to be fully solved. As I still am not able to access port 8000 through my browser. This time, when trying to run the Dockerfile without -d as suggested, I got the following error:

modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/5.10.52+/modules.dep.bin'
modprobe: FATAL: Module i2c-dev not found in directory /lib/modules/5.10.52+

I would like to check if I got the procedure correct, though, so please bare with me. Having built my own base image, editing the root directory's Dockerfile first line with FROM jozujo/balena-enviro-plus:v1 and the base image Dockerfile with FROM balenalib/raspberry-pi-debian-python:3.7-build, while still in the base_image folder, I did the following: docker build -t jozujo/balena-enviro-plus:v1 . This seemed largely successful, resulting in:

Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM balenalib/raspberry-pi-debian-python:3.7-build
3.7-build: Pulling from balenalib/raspberry-pi-debian-python
582c0d8b35e6: Pull complete 
c1a13b030fc8: Pull complete 
a90c1b2fa966: Pull complete 
1882c6e635ad: Pull complete 
f150a7025dff: Pull complete 
fa622207962a: Pull complete 
ef8bcc4a7006: Pull complete 
cdf3aa96d648: Pull complete 
536ddfa5c3d7: Pull complete 
460dd8852e94: Pull complete 
1b9f7356e3dc: Pull complete 
2f0f274543f4: Pull complete 
4f6d456f5ad1: Pull complete 
0cd6409b4463: Pull complete 
9c8c85f27c6c: Pull complete 
f3b063c7a236: Pull complete 
c196c58e79e4: Pull complete 
6b3073784dd0: Pull complete 
e45322636a2f: Pull complete 
02e477a58765: Pull complete 
adb76e046702: Pull complete 
6c866cf3e4e2: Pull complete 
4c520c990620: Pull complete 
9840fc2ae655: Pull complete 
b1eda90d828c: Pull complete 
b03c18dee673: Pull complete 
57ee4f6a1c25: Pull complete 
da329f632e64: Pull complete 
29f4d0495d25: Pull complete 
4c319ffb6a2f: Pull complete 
6679c119b0ae: Pull complete 
0736cd31a893: Pull complete 
5f3c8bc6d7fe: Pull complete 
Digest: sha256:9dcdba4ae271c4985e5b688fb6f6cc2515c07eb557b9022e2fae3be000cab66e
Status: Downloaded newer image for balenalib/raspberry-pi-debian-python:3.7-build
 ---> 5004154ec1ad
Step 2/4 : WORKDIR /usr/src
 ---> Running in 6dfacccaa423
Removing intermediate container 6dfacccaa423
 ---> 2b49d102fcda
Step 3/4 : RUN pip3 install enviroplus   requests   spidev   RPi.GPIO
 ---> Running in e41c60e1b72b
Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): 
Architecture: ARM v6 
OS: Debian Buster 
Variant: build variant 
Default variable(s): UDEV=off 
The following software stack is preinstalled: 
Python v3.7.11, Pip v21.2.3, Setuptools v57.4.0 
Extra features: 
- Easy way to install packages with `install_packages <package-name>` command 
- Run anywhere with cross-build feature  (for ARM only) 
- Keep the container idling with `balena-idle` command 
- Show base image details with `balena-info` command
Collecting enviroplus
  Downloading enviroplus-0.0.3-py3-none-any.whl (5.8 kB)
Collecting requests
  Using cached requests-2.26.0-py2.py3-none-any.whl (62 kB)
Collecting spidev
  Downloading spidev-3.5.tar.gz (10 kB)
Collecting RPi.GPIO
  Downloading RPi.GPIO-0.7.0.tar.gz (30 kB)
Collecting ads1015
  Downloading ads1015-0.0.6-py2.py3-none-any.whl (5.9 kB)
Collecting pytz
  Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
Requirement already satisfied: setuptools>=30.4.0 in /usr/local/lib/python3.7/site-packages (from enviroplus) (57.4.0)
Collecting ltr559
  Downloading ltr559-0.1.1-py3-none-any.whl (8.2 kB)
Collecting fonts
  Downloading fonts-0.0.3-py3-none-any.whl (4.2 kB)
Collecting astral
  Downloading astral-2.2-py2.py3-none-any.whl (30 kB)
Collecting pimoroni-bme280
  Downloading pimoroni_bme280-0.1.1-py3-none-any.whl (5.5 kB)
Collecting pms5003
  Downloading pms5003-0.0.5-py3-none-any.whl (4.4 kB)
Collecting font-roboto
  Downloading font-roboto-0.0.1.tar.gz (2.4 MB)
Collecting st7735
  Downloading ST7735-0.0.4-py3-none-any.whl (7.5 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.2-py3-none-any.whl (59 kB)
Collecting charset-normalizer~=2.0.0
  Using cached charset_normalizer-2.0.4-py3-none-any.whl (36 kB)
Collecting i2cdevice>=0.0.6
  Downloading i2cdevice-0.0.7-py3-none-any.whl (7.2 kB)
Collecting pyserial
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
Using legacy 'setup.py install' for spidev, since package 'wheel' is not installed.
Using legacy 'setup.py install' for RPi.GPIO, since package 'wheel' is not installed.
Using legacy 'setup.py install' for font-roboto, since package 'wheel' is not installed.
Installing collected packages: spidev, pytz, pyserial, i2cdevice, urllib3, st7735, pms5003, pimoroni-bme280, ltr559, idna, fonts, font-roboto, charset-normalizer, certifi, astral, ads1015, RPi.GPIO, requests, enviroplus
    Running setup.py install for spidev: started
    Running setup.py install for spidev: finished with status 'done'
    Running setup.py install for font-roboto: started
    Running setup.py install for font-roboto: finished with status 'done'
    Running setup.py install for RPi.GPIO: started
    Running setup.py install for RPi.GPIO: still running...
    Running setup.py install for RPi.GPIO: finished with status 'done'
Successfully installed RPi.GPIO-0.7.0 ads1015-0.0.6 astral-2.2 certifi-2021.5.30 charset-normalizer-2.0.4 enviroplus-0.0.3 font-roboto-0.0.1 fonts-0.0.3 i2cdevice-0.0.7 idna-3.2 ltr559-0.1.1 pimoroni-bme280-0.1.1 pms5003-0.0.5 pyserial-3.5 pytz-2021.1 requests-2.26.0 spidev-3.5 st7735-0.0.4 urllib3-1.26.6
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
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/usr/local/bin/python3.7 -m pip install --upgrade pip' command.
Removing intermediate container e41c60e1b72b
 ---> 9b2a859a1a75
Step 4/4 : RUN install_packages   python3-smbus   python3-pil   libatlas-base-dev   python3-dev   python3-setuptools   python3-numpy
 ---> Running in f6c3559e891d
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  dh-python libatlas3-base libblas3 libexpat1-dev libgfortran5 libimagequant0
  liblapack3 libpython3-dev libpython3.7 libpython3.7-dev libwebpdemux2
  python3-pkg-resources python3.7-dev
Suggested packages:
  libatlas-doc liblapack-doc gfortran python-numpy-doc python3-pytest
  python3-numpy-dbg python-pil-doc python3-pil-dbg python-setuptools-doc
Recommended packages:
  python3-olefile
The following NEW packages will be installed:
  dh-python libatlas-base-dev libatlas3-base libblas3 libexpat1-dev
  libgfortran5 libimagequant0 liblapack3 libpython3-dev libpython3.7
  libpython3.7-dev libwebpdemux2 python3-dev python3-numpy python3-pil
  python3-pkg-resources python3-setuptools python3-smbus python3.7-dev
0 upgraded, 19 newly installed, 0 to remove and 19 not upgraded.
Need to get 59.2 MB of archives.
After this operation, 130 MB of additional disk space will be used.
Get:1 http://archive.raspbian.org/raspbian buster/main armhf dh-python all 3.20190308 [99.3 kB]
Get:2 http://archive.raspbian.org/raspbian buster/main armhf libgfortran5 armhf 8.3.0-6+rpi1 [206 kB]
Get:3 http://archive.raspbian.org/raspbian buster/main armhf libatlas3-base armhf 3.10.3-8+rpi1 [2399 kB]
Get:4 http://archive.raspbian.org/raspbian buster/main armhf libatlas-base-dev armhf 3.10.3-8+rpi1 [2966 kB]
Get:5 http://archive.raspbian.org/raspbian buster/main armhf libblas3 armhf 3.8.0-2 [103 kB]
Get:6 http://archive.raspbian.org/raspbian buster/main armhf libexpat1-dev armhf 2.2.6-2+deb10u1 [127 kB]
Get:7 http://archive.raspbian.org/raspbian buster/main armhf libimagequant0 armhf 2.12.2-1.1 [27.2 kB]
Get:8 http://archive.raspbian.org/raspbian buster/main armhf liblapack3 armhf 3.8.0-2 [1493 kB]
Get:9 http://archive.raspbian.org/raspbian buster/main armhf libpython3.7 armhf 3.7.3-2+deb10u3 [1253 kB]
Get:10 http://archive.raspbian.org/raspbian buster/main armhf libpython3.7-dev armhf 3.7.3-2+deb10u3 [47.2 MB]
Get:11 http://archive.raspbian.org/raspbian buster/main armhf libpython3-dev armhf 3.7.3-1 [20.1 kB]
Get:12 http://archive.raspbian.org/raspbian buster/main armhf libwebpdemux2 armhf 0.6.1-2+deb10u1 [86.7 kB]
Get:13 http://archive.raspbian.org/raspbian buster/main armhf python3.7-dev armhf 3.7.3-2+deb10u3 [513 kB]
Get:14 http://archive.raspbian.org/raspbian buster/main armhf python3-dev armhf 3.7.3-1 [1264 B]
Get:15 http://archive.raspbian.org/raspbian buster/main armhf python3-pkg-resources all 40.8.0-1 [153 kB]
Get:16 http://archive.raspbian.org/raspbian buster/main armhf python3-numpy armhf 1:1.16.2-1 [1873 kB]
Get:17 http://archive.raspbian.org/raspbian buster/main armhf python3-pil armhf 5.4.1-2+deb10u2 [365 kB]
Get:18 http://archive.raspbian.org/raspbian buster/main armhf python3-setuptools all 40.8.0-1 [306 kB]
Get:19 http://archive.raspbian.org/raspbian buster/main armhf python3-smbus armhf 4.1-1 [11.7 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 59.2 MB in 1min 19s (748 kB/s)
Selecting previously unselected package dh-python.
(Reading database ... 20464 files and directories currently installed.)
Preparing to unpack .../00-dh-python_3.20190308_all.deb ...
Unpacking dh-python (3.20190308) ...
Selecting previously unselected package libgfortran5:armhf.
Preparing to unpack .../01-libgfortran5_8.3.0-6+rpi1_armhf.deb ...
Unpacking libgfortran5:armhf (8.3.0-6+rpi1) ...
Selecting previously unselected package libatlas3-base:armhf.
Preparing to unpack .../02-libatlas3-base_3.10.3-8+rpi1_armhf.deb ...
Unpacking libatlas3-base:armhf (3.10.3-8+rpi1) ...
Selecting previously unselected package libatlas-base-dev:armhf.
Preparing to unpack .../03-libatlas-base-dev_3.10.3-8+rpi1_armhf.deb ...
Unpacking libatlas-base-dev:armhf (3.10.3-8+rpi1) ...
Selecting previously unselected package libblas3:armhf.
Preparing to unpack .../04-libblas3_3.8.0-2_armhf.deb ...
Unpacking libblas3:armhf (3.8.0-2) ...
Selecting previously unselected package libexpat1-dev:armhf.
Preparing to unpack .../05-libexpat1-dev_2.2.6-2+deb10u1_armhf.deb ...
Unpacking libexpat1-dev:armhf (2.2.6-2+deb10u1) ...
Selecting previously unselected package libimagequant0:armhf.
Preparing to unpack .../06-libimagequant0_2.12.2-1.1_armhf.deb ...
Unpacking libimagequant0:armhf (2.12.2-1.1) ...
Selecting previously unselected package liblapack3:armhf.
Preparing to unpack .../07-liblapack3_3.8.0-2_armhf.deb ...
Unpacking liblapack3:armhf (3.8.0-2) ...
Selecting previously unselected package libpython3.7:armhf.
Preparing to unpack .../08-libpython3.7_3.7.3-2+deb10u3_armhf.deb ...
Unpacking libpython3.7:armhf (3.7.3-2+deb10u3) ...
Selecting previously unselected package libpython3.7-dev:armhf.
Preparing to unpack .../09-libpython3.7-dev_3.7.3-2+deb10u3_armhf.deb ...
Unpacking libpython3.7-dev:armhf (3.7.3-2+deb10u3) ...
Selecting previously unselected package libpython3-dev:armhf.
Preparing to unpack .../10-libpython3-dev_3.7.3-1_armhf.deb ...
Unpacking libpython3-dev:armhf (3.7.3-1) ...
Selecting previously unselected package libwebpdemux2:armhf.
Preparing to unpack .../11-libwebpdemux2_0.6.1-2+deb10u1_armhf.deb ...
Unpacking libwebpdemux2:armhf (0.6.1-2+deb10u1) ...
Selecting previously unselected package python3.7-dev.
Preparing to unpack .../12-python3.7-dev_3.7.3-2+deb10u3_armhf.deb ...
Unpacking python3.7-dev (3.7.3-2+deb10u3) ...
Selecting previously unselected package python3-dev.
Preparing to unpack .../13-python3-dev_3.7.3-1_armhf.deb ...
Unpacking python3-dev (3.7.3-1) ...
Selecting previously unselected package python3-pkg-resources.
Preparing to unpack .../14-python3-pkg-resources_40.8.0-1_all.deb ...
Unpacking python3-pkg-resources (40.8.0-1) ...
Selecting previously unselected package python3-numpy.
Preparing to unpack .../15-python3-numpy_1%3a1.16.2-1_armhf.deb ...
Unpacking python3-numpy (1:1.16.2-1) ...
Selecting previously unselected package python3-pil:armhf.
Preparing to unpack .../16-python3-pil_5.4.1-2+deb10u2_armhf.deb ...
Unpacking python3-pil:armhf (5.4.1-2+deb10u2) ...
Selecting previously unselected package python3-setuptools.
Preparing to unpack .../17-python3-setuptools_40.8.0-1_all.deb ...
Unpacking python3-setuptools (40.8.0-1) ...
Selecting previously unselected package python3-smbus:armhf.
Preparing to unpack .../18-python3-smbus_4.1-1_armhf.deb ...
Unpacking python3-smbus:armhf (4.1-1) ...
Setting up python3-pkg-resources (40.8.0-1) ...
Setting up dh-python (3.20190308) ...
Setting up python3-setuptools (40.8.0-1) ...
Setting up libpython3.7:armhf (3.7.3-2+deb10u3) ...
Setting up libwebpdemux2:armhf (0.6.1-2+deb10u1) ...
Setting up libexpat1-dev:armhf (2.2.6-2+deb10u1) ...
Setting up libimagequant0:armhf (2.12.2-1.1) ...
Setting up libgfortran5:armhf (8.3.0-6+rpi1) ...
Setting up python3-smbus:armhf (4.1-1) ...
Setting up libatlas3-base:armhf (3.10.3-8+rpi1) ...
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/libblas.so.3 to provide /usr/lib/arm-linux-gnueabihf/libblas.so.3 (libblas.so.3-arm-linux-gnueabihf) in auto mode
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/liblapack.so.3 to provide /usr/lib/arm-linux-gnueabihf/liblapack.so.3 (liblapack.so.3-arm-linux-gnueabihf) in auto mode
Setting up libpython3.7-dev:armhf (3.7.3-2+deb10u3) ...
Setting up python3.7-dev (3.7.3-2+deb10u3) ...
Setting up libatlas-base-dev:armhf (3.10.3-8+rpi1) ...
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/libblas.so to provide /usr/lib/arm-linux-gnueabihf/libblas.so (libblas.so-arm-linux-gnueabihf) in auto mode
update-alternatives: using /usr/lib/arm-linux-gnueabihf/atlas/liblapack.so to provide /usr/lib/arm-linux-gnueabihf/liblapack.so (liblapack.so-arm-linux-gnueabihf) in auto mode
Setting up python3-pil:armhf (5.4.1-2+deb10u2) ...
Setting up libblas3:armhf (3.8.0-2) ...
Setting up python3-numpy (1:1.16.2-1) ...
Setting up liblapack3:armhf (3.8.0-2) ...
Setting up libpython3-dev:armhf (3.7.3-1) ...
Setting up python3-dev (3.7.3-1) ...
Processing triggers for libc-bin (2.28-10+rpi1) ...
Removing intermediate container f6c3559e891d
 ---> eda628192dcb
Successfully built eda628192dcb
Successfully tagged jozujo/balena-enviro-plus:v1

Then, going up a directory to the balena-enviro-plus directory, I ran: docker build -t jozujo/enviroplus_exporter:v1 .

Sending build context to Docker daemon  2.749MB
Step 1/16 : FROM jozujo/balena-enviro-plus:v1
 ---> eda628192dcb
Step 2/16 : WORKDIR /usr/src
 ---> Running in 8ff02dd5be8b
Removing intermediate container 8ff02dd5be8b
 ---> 3f8f8e9d72da
Step 3/16 : RUN sudo pip3 install --upgrade setuptools && sudo pip3 install     adafruit-circuitpython-lc709203f     influxdb-client     prometheus_client     python-periphery     SafecastPy
 ---> Running in a4fb4777f7d6
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (57.4.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
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/usr/local/bin/python3.7 -m pip install --upgrade pip' command.
Collecting adafruit-circuitpython-lc709203f
  Downloading adafruit-circuitpython-lc709203f-2.1.0.tar.gz (28 kB)
  Installing build dependencies: started
  Installing build dependencies: still running...
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: still running...
  Installing backend dependencies: still running...
  Installing backend dependencies: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting influxdb-client
  Downloading influxdb_client-1.20.0-py3-none-any.whl (505 kB)
Collecting prometheus_client
  Downloading prometheus_client-0.11.0-py2.py3-none-any.whl (56 kB)
Collecting python-periphery
  Downloading python_periphery-2.3.0-py2.py3-none-any.whl (25 kB)
Collecting SafecastPy
  Downloading SafecastPy-0.1.1-py2.py3-none-any.whl (7.1 kB)
Collecting Adafruit-Blinka
  Downloading Adafruit-Blinka-6.13.0.tar.gz (142 kB)
Collecting adafruit-circuitpython-busdevice
  Downloading adafruit-circuitpython-busdevice-5.0.6.tar.gz (27 kB)
Collecting adafruit-circuitpython-register
  Downloading adafruit-circuitpython-register-1.9.5.tar.gz (33 kB)
Collecting six>=1.10
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Requirement already satisfied: setuptools>=21.0.0 in /usr/local/lib/python3.7/site-packages (from influxdb-client) (57.4.0)
Requirement already satisfied: pytz>=2019.1 in /usr/local/lib/python3.7/site-packages (from influxdb-client) (2021.1)
Requirement already satisfied: urllib3>=1.15.1 in /usr/local/lib/python3.7/site-packages (from influxdb-client) (1.26.6)
Collecting python-dateutil>=2.5.3
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting rx>=3.0.1
  Downloading Rx-3.2.0-py3-none-any.whl (199 kB)
Requirement already satisfied: certifi>=14.05.14 in /usr/local/lib/python3.7/site-packages (from influxdb-client) (2021.5.30)
Requirement already satisfied: requests>=2.9.1 in /usr/local/lib/python3.7/site-packages (from SafecastPy) (2.26.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.9.1->SafecastPy) (3.2)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.7/site-packages (from requests>=2.9.1->SafecastPy) (2.0.4)
Collecting Adafruit-PlatformDetect>=3.13.0
  Downloading Adafruit-PlatformDetect-3.15.3.tar.gz (31 kB)
Collecting Adafruit-PureIO>=1.1.7
  Downloading Adafruit_PureIO-1.1.9.tar.gz (26 kB)
Collecting pyftdi>=0.40.0
  Downloading pyftdi-0.53.3-py3-none-any.whl (141 kB)
Requirement already satisfied: pyserial>=3.0 in /usr/local/lib/python3.7/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-lc709203f) (3.5)
Collecting pyusb!=1.2.0,>=1.0.0
  Downloading pyusb-1.2.1-py3-none-any.whl (58 kB)
Using legacy 'setup.py install' for Adafruit-Blinka, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Adafruit-PlatformDetect, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Adafruit-PureIO, since package 'wheel' is not installed.
Using legacy 'setup.py install' for adafruit-circuitpython-busdevice, since package 'wheel' is not installed.
Using legacy 'setup.py install' for adafruit-circuitpython-register, since package 'wheel' is not installed.
Building wheels for collected packages: adafruit-circuitpython-lc709203f
  Building wheel for adafruit-circuitpython-lc709203f (PEP 517): started
  Building wheel for adafruit-circuitpython-lc709203f (PEP 517): finished with status 'done'
  Created wheel for adafruit-circuitpython-lc709203f: filename=adafruit_circuitpython_lc709203f-2.1.0-py3-none-any.whl size=5889 sha256=46e2df207ca1dcbd5dbabb083432fb029b5ac15a12af27c2ca14d8529ec64301
  Stored in directory: /root/.cache/pip/wheels/68/39/d6/da2c19837172b6c0f344d44aa3153be53035a2020b126848e2
Successfully built adafruit-circuitpython-lc709203f
Installing collected packages: pyusb, pyftdi, Adafruit-PureIO, Adafruit-PlatformDetect, six, Adafruit-Blinka, rx, python-dateutil, adafruit-circuitpython-register, adafruit-circuitpython-busdevice, SafecastPy, python-periphery, prometheus-client, influxdb-client, adafruit-circuitpython-lc709203f
    Running setup.py install for Adafruit-PureIO: started
    Running setup.py install for Adafruit-PureIO: finished with status 'done'
    Running setup.py install for Adafruit-PlatformDetect: started
    Running setup.py install for Adafruit-PlatformDetect: finished with status 'done'
    Running setup.py install for Adafruit-Blinka: started
    Running setup.py install for Adafruit-Blinka: finished with status 'done'
    Running setup.py install for adafruit-circuitpython-register: started
    Running setup.py install for adafruit-circuitpython-register: finished with status 'done'
    Running setup.py install for adafruit-circuitpython-busdevice: started
    Running setup.py install for adafruit-circuitpython-busdevice: finished with status 'done'
Successfully installed Adafruit-Blinka-6.13.0 Adafruit-PlatformDetect-3.15.3 Adafruit-PureIO-1.1.9 SafecastPy-0.1.1 adafruit-circuitpython-busdevice-5.0.6 adafruit-circuitpython-lc709203f-2.1.0 adafruit-circuitpython-register-1.9.5 influxdb-client-1.20.0 prometheus-client-0.11.0 pyftdi-0.53.3 python-dateutil-2.8.2 python-periphery-2.3.0 pyusb-1.2.1 rx-3.2.0 six-1.16.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
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/usr/local/bin/python3.7 -m pip install --upgrade pip' command.
Removing intermediate container a4fb4777f7d6
 ---> 3fb9a9162e61
Step 4/16 : COPY enviroplus_exporter/enviroplus_exporter.py enviroplus_exporter.py
 ---> f49c15b304cb
Step 5/16 : COPY enviroplus_exporter/notecard/notecard/notecard.py notecard/notecard/notecard.py
 ---> 9f2c14ee68d7
Step 6/16 : ENV INFLUXDB_URL="https://ap-southeast-2-1.aws.cloud2.influxdata.com"
 ---> Running in 5587d0968b71
Removing intermediate container 5587d0968b71
 ---> 131acc0184dd
Step 7/16 : ENV INFLUXDB_TOKEN="[REDACTED]"
 ---> Running in 019b461f1559
Removing intermediate container 019b461f1559
 ---> ab8f1be732c9
Step 8/16 : ENV INFLUXDB_ORG_ID="[REDACTED]"
 ---> Running in 0f4936de6f95
Removing intermediate container 0f4936de6f95
 ---> bf328bc20b82
Step 9/16 : ENV INFLUXDB_BUCKET="[REDACTED]"
 ---> Running in 36b2631df404
Removing intermediate container 36b2631df404
 ---> 25fd72b05577
Step 10/16 : ENV INFLUXDB_SENSOR_LOCATION="[REDACTED]"
 ---> Running in fcb1dbf1ffb8
Removing intermediate container fcb1dbf1ffb8
 ---> a16169445686
Step 11/16 : ENV INFLUXDB_TIME_BETWEEN_POSTS="300"
 ---> Running in f986fb1f4a48
Removing intermediate container f986fb1f4a48
 ---> 1cdf1908c423
Step 12/16 : ENV LUFTDATEN_TIME_BETWEEN_POSTS="30"
 ---> Running in 233c4c626717
Removing intermediate container 233c4c626717
 ---> cb856051842f
Step 13/16 : ENV DEBUG="true"
 ---> Running in fa7ebb8950f1
Removing intermediate container fa7ebb8950f1
 ---> 0936eee195e1
Step 14/16 : ENV TEMPERATURE_COMPENSATION="6.6"
 ---> Running in a44c07c86345
Removing intermediate container a44c07c86345
 ---> f0ffc483f2a8
Step 15/16 : ENV HUMIDITY_COMPENSATION="24.7"
 ---> Running in 9880661b0cd8
Removing intermediate container 9880661b0cd8
 ---> 7f2684a4b914
Step 16/16 : CMD ["sh", "-c", "modprobe i2c-dev && python3 enviroplus_exporter.py --temp $TEMPERATURE_COMPENSATION --humid $HUMIDITY_COMPENSATION --influxdb true --luftdaten true"]
 ---> Running in 60884fd9a2e3
Removing intermediate container 60884fd9a2e3
 ---> 5a3b947690d6
Successfully built 5a3b947690d6
Successfully tagged jozujo/enviroplus_exporter:v1

But then running docker run --privileged -p 8000:8000 jozujo/enviroplus_exporter:v1 resulted in the error at the top of this post, with seemingly no active containers...

sighmon commented 3 years ago

@jozujo @asdfng Okay, so at least you've both got the same error there. What happens if you remove modprobe i2c-dev && from the Dockerfile in the root folder?

jozujo commented 3 years ago

@sighmon Hi, thank you for being so patient with me on this - I really owe you more than a pat on the back after all of this.

I removed modprobe i2c-dev && from the Dockerfile in the root folder to have the final line read:

# Uses temperature compensation of 6.6 and humidity compensation of 24.7 and posts to influxdb and luftdaten
CMD ["sh", "-c", python3 enviroplus_exporter.py --temp $TEMPERATURE_COMPENSATION --humid $HUMIDITY_COMPENSATION --influxdb true --luftdaten true"]

Then, going through the same process as my previous post, running docker run --privileged -p 8000:8000 jozujo/enviroplus_exporter:v1, I get the following error:

/bin/sh: 1: Syntax error: Unterminated quoted string

I confirmed that there was no active container running and was not able to access the data locally through port 8000.

sighmon commented 3 years ago

@jozujo Try adding the " before python3... so:

CMD ["sh", "-c", "python3 enviroplus_exporter.py --temp $TEMPERATURE_COMPENSATION --humid $HUMIDITY_COMPENSATION --influxdb true --luftdaten true"]

jozujo commented 3 years ago

@sighmon Still no luck I'm afraid, but I feel like we're getting close. This time, I had the following readout:

Traceback (most recent call last):
  File "enviroplus_exporter.py", line 24, in <module>
    from adafruit_lc709203f import LC709023F, PackSize
ImportError: cannot import name 'LC709023F' from 'adafruit_lc709203f' (/usr/local/lib/python3.7/site-packages/adafruit_lc709203f.py)

I guess this means I need to change something with the line below in the root Dockerfile?

    adafruit-circuitpython-lc709203f \
sighmon commented 3 years ago

@jozujo That's very weird, were you definitely running the right image? We might have to coordinate some realtime help to debug this last bit. Which timezone are you in?

jozujo commented 3 years ago

@sighmon I think I'm using the right image. Because I've gone back and forth a lot on this case, there is a high possibility that I've messed with something without realizing it, so I'm going to try and do a totally fresh reinstall of the OS and this project and see if I get the same results. If that does end up happening, I would really appreciate your help with a realtime debug - I'm in Tokyo, so I don't think it should be too hard to coordinate with yourself in Australia hopefully. Thanks for all your help so far!

sighmon commented 3 years ago

@jozujo I've just noticed that on one of mine I'm running the command without the "sh", "-c" part. So maybe try this with all extras turned off just to get it running:

CMD ["python3", "enviroplus_exporter.py", "--temp", "6.6", "--humid", "24.7", "--influxdb", "false", "--luftdaten", "false", "--safecast", "false", "--notecard", "false"]

jozujo commented 3 years ago

@sighmon Unfortunately I got the same error:

docker run --privileged -p 8000:8000 jozujo/enviroplus_exporter:v1
Traceback (most recent call last):
  File "enviroplus_exporter.py", line 24, in <module>
    from adafruit_lc709203f import LC709023F, PackSize
ImportError: cannot import name 'LC709023F' from 'adafruit_lc709203f' (/usr/local/lib/python3.7/site-packages/adafruit_lc709203f.py)

I'm going to try and start from scratch and will report back.

jozujo commented 3 years ago

Hi @sighmon , apologies for the long silence. I went back and started totally fresh on a reinstalled OS, but I'm afraid I haven't had any luck. This time, when I changed the base image Dockerfile's first line to read: FROM balenalib/raspberry-pi-debian-python:3.7-build as you suggested earlier, I got the following error after Step 3/4(Step 4 was never completed):

Fatal Python error: _Py_InitializeMainInterpreter: can't initialize time
PermissionError: [Errno 1] Operation not permitted

Current thread 0xb6f41040 (most recent call first):
Aborted (core dumped)
The command '/bin/sh -c pip3 install enviroplus   requests   spidev   RPi.GPIO' returned a non-zero code: 134

Nevertheless, I tried to run the final version of the root Dockerfile (with everything turned off as suggested here), which reads as follows:

### Export all of the enviro+ sensor data to a Prometheus exporter ###

# Built from /base_image/Dockerfile
FROM jozujo/balena-enviro-plus:v1

WORKDIR /usr/src
RUN sudo pip3 install --upgrade setuptools && sudo pip3 install \
    adafruit-circuitpython-lc709203f \
    influxdb-client \
    prometheus_client \
    python-periphery \
    SafecastPy
COPY enviroplus_exporter/enviroplus_exporter.py enviroplus_exporter.py
COPY enviroplus_exporter/notecard/notecard/notecard.py notecard/notecard/notecard.py

# InfluxDB settings
ENV INFLUXDB_URL="[REDACTED]"
ENV INFLUXDB_TOKEN="[REDACTED]"
ENV INFLUXDB_ORG_ID=“[REDACTED]”
ENV INFLUXDB_BUCKET=“[REDACTED]”
ENV INFLUXDB_SENSOR_LOCATION=“[REDACTED]”
ENV INFLUXDB_TIME_BETWEEN_POSTS=“30”

# Luftdaten settings
ENV LUFTDATEN_TIME_BETWEEN_POSTS="30"

# Safecast settings
# ENV SAFECAST_TIME_BETWEEN_POSTS="300"
# ENV SAFECAST_DEV_MODE="false"
# ENV SAFECAST_API_KEY="your_api_key"
# ENV SAFECAST_API_KEY_DEV="your_dev_api_key"
# ENV SAFECAST_LATITUDE="your_sensor_latitude"
# ENV SAFECAST_LONGITUDE="your_sensor_longitude"
# ENV SAFECAST_DEVICE_ID="226"
# ENV SAFECAST_LOCATION_NAME="your_sensor_location"

# Blues Notecard settings
ENV NOTECARD_TIME_BETWEEN_POSTS="600"

# See debug output
ENV DEBUG="true"

# Compensation factor OR temperature/humidity adjustment to take into account the CPU temperature
# ENV COMPENSATION_FACTOR="2.25"
ENV TEMPERATURE_COMPENSATION="6.6"
ENV HUMIDITY_COMPENSATION="24.7"

# Uses temperature adjustment factor of 2.25 and also posts to all other services
# CMD ["sh", "-c", "modprobe i2c-dev && python3 enviroplus_exporter.py --factor $COMPENSATION_FACTOR --influxdb true --luftdaten true --safecast true --notecard false"]

# Uses temperature compensation of 6.6 and humidity compensation of 24.7 and posts to influxdb and luftdaten
CMD ["python3", "enviroplus_exporter.py", "--temp", "6.6", "--humid", "24.7", "--influxdb", "false", "--luftdaten", "false", "--safecast", "false", "--notecard", "false"]

I ended up getting the same error as last time, though:

pi@raspberrypi:~/balena-enviro-plus $ docker run --privileged -p 8000:8000 jozujo/enviroplus_exporter:v1
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
Traceback (most recent call last):
  File "enviroplus_exporter.py", line 25, in <module>
    from adafruit_lc709203f import LC709023F, PackSize
ImportError: cannot import name 'LC709023F' from 'adafruit_lc709203f' (/usr/local/lib/python3.7/site-packages/adafruit_lc709203f.py)

If you have time we may need to coordinate that realtime help you mentioned. Please let me know if you have any other ideas though!

Thanks a lot for all your help so far!

sighmon commented 3 years ago

@jozujo Eep! It's a typo in the Adafruit library which they fixed... which then broke this code. Sorry! I'll get to fixing it shortly.

sighmon commented 3 years ago

@jozujo Okay, try a git pull on the master branch, and see how you get along.

jozujo commented 3 years ago

@sighmon Thanks for the help. I tried, but still no luck. I am getting the following error when I try to build the base image, which I think is impacting the rest of the progress after that.

docker build -t jozujo/balena-enviro-plus:v1 .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM balenalib/raspberry-pi-debian-python:3.7-build
 ---> d4f0598c1452
Step 2/4 : WORKDIR /usr/src
 ---> Using cache
 ---> 6895dc188adc
Step 3/4 : RUN pip3 install enviroplus   requests   spidev   RPi.GPIO
 ---> Running in 8b9520ad8e60
Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): 
Architecture: ARM v6 
OS: Debian Bullseye 
Variant: build variant 
Default variable(s): UDEV=off 
The following software stack is preinstalled: 
Python v3.7.12, Pip v21.2.4, Setuptools v58.0.0 
Extra features: 
- Easy way to install packages with `install_packages <package-name>` command 
- Run anywhere with cross-build feature  (for ARM only) 
- Keep the container idling with `balena-idle` command 
- Show base image details with `balena-info` command
Fatal Python error: _Py_InitializeMainInterpreter: can't initialize time
PermissionError: [Errno 1] Operation not permitted

Current thread 0xb6fc6040 (most recent call first):
Aborted (core dumped)
The command '/bin/sh -c pip3 install enviroplus   requests   spidev   RPi.GPIO' returned a non-zero code: 134

Continuing the process with docker build -t jozujo/enviroplus_exporter:v1 ., it seemed to execute without errors:

Sending build context to Docker daemon  2.679MB
Step 1/17 : FROM jozujo/balena-enviro-plus:v1
 ---> 8209e6b1216f
Step 2/17 : WORKDIR /usr/src
 ---> Using cache
 ---> ba2370b27b10
Step 3/17 : RUN sudo pip3 install --upgrade setuptools && sudo pip3 install     adafruit-circuitpython-lc709203f     influxdb-client     prometheus_client     python-periphery     SafecastPy
 ---> Using cache
 ---> 0c5c6703b1d8
Step 4/17 : COPY enviroplus_exporter/enviroplus_exporter.py enviroplus_exporter.py
 ---> Using cache
 ---> 06cfaee30ed8
Step 5/17 : COPY enviroplus_exporter/notecard/notecard/notecard.py notecard/notecard/notecard.py
 ---> Using cache
 ---> ae0d6d8fcba2
Step 6/17 : ENV INFLUXDB_URL="[REDACTED]"
 ---> Using cache
 ---> 258e15e128d4
Step 7/17 : ENV INFLUXDB_TOKEN="[REDACTED]"
 ---> Using cache
 ---> 69fc64e1c7c4
Step 8/17 : ENV INFLUXDB_ORG_ID="[REDACTED]"
 ---> Using cache
 ---> 1cd1197c6031
Step 9/17 : ENV INFLUXDB_BUCKET="[REDACTED]"
 ---> Using cache
 ---> 7ab9c5761fc7
Step 10/17 : ENV INFLUXDB_SENSOR_LOCATION="[REDACTED]"
 ---> Using cache
 ---> 0d7623ba1a29
Step 11/17 : ENV INFLUXDB_TIME_BETWEEN_POSTS="300"
 ---> Using cache
 ---> 816dcb3a8d57
Step 12/17 : ENV LUFTDATEN_TIME_BETWEEN_POSTS="30"
 ---> Using cache
 ---> 56dce125e9be
Step 13/17 : ENV NOTECARD_TIME_BETWEEN_POSTS="600"
 ---> Using cache
 ---> 8707e2ecec80
Step 14/17 : ENV DEBUG="true"
 ---> Using cache
 ---> f926dd815335
Step 15/17 : ENV TEMPERATURE_COMPENSATION="6.6"
 ---> Using cache
 ---> 5406fd30648f
Step 16/17 : ENV HUMIDITY_COMPENSATION="24.7"
 ---> Using cache
 ---> dd46eb1149e9
Step 17/17 : CMD ["python3", "enviroplus_exporter.py", "--temp", "6.6", "--humid", "24.7", "--influxdb", "false", "--luftdaten", "false", "--safecast", "false", "--notecard", "false"]
 ---> Using cache
 ---> 9b200a1bfa9a
Successfully built 9b200a1bfa9a
Successfully tagged jozujo/enviroplus_exporter:v1

But, then, when running the Docker image docker run --privileged -p 8000:8000 jozujo/enviroplus_exporter:v1, I got these error messages.

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
2021-11-14 04:51:19.476 INFO     enviroplus_exporter.py - Expose readings from the Enviro+ sensor by Pimoroni in Prometheus format

Press Ctrl+C to exit!

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 154, in __probe_for_device
    self.i2c.writeto(self.device_address, b"")
  File "/usr/local/lib/python3.7/site-packages/busio.py", line 166, in writeto
    return self._i2c.writeto(address, buffer, stop=stop)
  File "/usr/local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 49, in writeto
    self._i2c_bus.write_bytes(address, buffer[start:end])
  File "/usr/local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
    self._device.write(buf)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 160, in __probe_for_device
    self.i2c.readfrom_into(self.device_address, result)
  File "/usr/local/lib/python3.7/site-packages/busio.py", line 156, in readfrom_into
    return self._i2c.readfrom_into(address, buffer, stop=stop)
  File "/usr/local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 56, in readfrom_into
    readin = self._i2c_bus.read_bytes(address, end - start)
  File "/usr/local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 181, in read_bytes
    return self._device.read(number)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "enviroplus_exporter.py", line 55, in <module>
    sensor = LC709203F(board.I2C())
  File "/usr/local/lib/python3.7/site-packages/adafruit_lc709203f.py", line 116, in __init__
    self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 50, in __init__
    self.__probe_for_device()
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 163, in __probe_for_device
    raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0xb
sighmon commented 3 years ago

@jozujo Could you please try using my base image again, because I think we can ignore the warning you were seeing.

When you reinstalled Raspbian did you also enable i2c using sudo raspi-config?

What do you see when you run: i2cdetect -y 1

jozujo commented 3 years ago

@sighmon It feels like we're getting closer. This time seemed more successful than my previous recent attempts. I reverted to your base image Dockerfile, and executed docker build -t jozujo/balena-enviro-plus:v1 .:

Sending build context to Docker daemon  3.072kB
Step 1/4 : FROM balenalib/raspberry-pi-debian-python:3.7.4-build
 ---> 4dcde83c7d05
Step 2/4 : WORKDIR /usr/src
 ---> Using cache
 ---> 9a3d2bf11153
Step 3/4 : RUN pip3 install enviroplus   requests   spidev   RPi.GPIO
 ---> Using cache
 ---> 179e7b5c8020
Step 4/4 : RUN install_packages   python3-smbus   python3-pil   libatlas-base-dev   python3-dev   python3-setuptools   python3-numpy
 ---> Using cache
 ---> 8209e6b1216f
Successfully built 8209e6b1216f
Successfully tagged jozujo/balena-enviro-plus:v1

Then, going up a directly to balena-enviro-plus, I executed docker build -t jozujo/enviroplus_exporter:v1 .:

Sending build context to Docker daemon   2.68MB
Step 1/17 : FROM jozujo/balena-enviro-plus:v1
 ---> 8209e6b1216f
Step 2/17 : WORKDIR /usr/src
 ---> Using cache
 ---> ba2370b27b10
Step 3/17 : RUN sudo pip3 install --upgrade setuptools && sudo pip3 install     adafruit-circuitpython-lc709203f     influxdb-client     prometheus_client     python-periphery     SafecastPy
 ---> Using cache
 ---> 0c5c6703b1d8
Step 4/17 : COPY enviroplus_exporter/enviroplus_exporter.py enviroplus_exporter.py
 ---> Using cache
 ---> 06cfaee30ed8
Step 5/17 : COPY enviroplus_exporter/notecard/notecard/notecard.py notecard/notecard/notecard.py
 ---> Using cache
 ---> ae0d6d8fcba2
Step 6/17 : ENV INFLUXDB_URL="[REDACTED]"
 ---> Using cache
 ---> 258e15e128d4
Step 7/17 : ENV INFLUXDB_TOKEN="[REDACTED]"
 ---> Using cache
 ---> 69fc64e1c7c4
Step 8/17 : ENV INFLUXDB_ORG_ID="[REDACTED]"
 ---> Using cache
 ---> 1cd1197c6031
Step 9/17 : ENV INFLUXDB_BUCKET="[REDACTED]"
 ---> Using cache
 ---> 7ab9c5761fc7
Step 10/17 : ENV INFLUXDB_SENSOR_LOCATION="[REDACTED]"
 ---> Using cache
 ---> 0d7623ba1a29
Step 11/17 : ENV INFLUXDB_TIME_BETWEEN_POSTS="300"
 ---> Using cache
 ---> 816dcb3a8d57
Step 12/17 : ENV LUFTDATEN_TIME_BETWEEN_POSTS="30"
 ---> Using cache
 ---> 56dce125e9be
Step 13/17 : ENV NOTECARD_TIME_BETWEEN_POSTS="600"
 ---> Using cache
 ---> 8707e2ecec80
Step 14/17 : ENV DEBUG="true"
 ---> Using cache
 ---> f926dd815335
Step 15/17 : ENV TEMPERATURE_COMPENSATION="6.6"
 ---> Using cache
 ---> 5406fd30648f
Step 16/17 : ENV HUMIDITY_COMPENSATION="24.7"
 ---> Using cache
 ---> dd46eb1149e9
Step 17/17 : CMD ["python3", "enviroplus_exporter.py", "--temp", "6.6", "--humid", "24.7", "--influxdb", "false", "--luftdaten", "false", "--safecast", "false", "--notecard", "false"]
 ---> Using cache
 ---> 9b200a1bfa9a
Successfully built 9b200a1bfa9a
Successfully tagged jozujo/enviroplus_exporter:v1

Then, I ran the image, but got the same result as last time:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested
2021-11-24 10:43:47.619 INFO     enviroplus_exporter.py - Expose readings from the Enviro+ sensor by Pimoroni in Prometheus format

Press Ctrl+C to exit!

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 154, in __probe_for_device
    self.i2c.writeto(self.device_address, b"")
  File "/usr/local/lib/python3.7/site-packages/busio.py", line 166, in writeto
    return self._i2c.writeto(address, buffer, stop=stop)
  File "/usr/local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 49, in writeto
    self._i2c_bus.write_bytes(address, buffer[start:end])
  File "/usr/local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 314, in write_bytes
    self._device.write(buf)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 160, in __probe_for_device
    self.i2c.readfrom_into(self.device_address, result)
  File "/usr/local/lib/python3.7/site-packages/busio.py", line 156, in readfrom_into
    return self._i2c.readfrom_into(address, buffer, stop=stop)
  File "/usr/local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 56, in readfrom_into
    readin = self._i2c_bus.read_bytes(address, end - start)
  File "/usr/local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 181, in read_bytes
    return self._device.read(number)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "enviroplus_exporter.py", line 55, in <module>
    sensor = LC709203F(board.I2C())
  File "/usr/local/lib/python3.7/site-packages/adafruit_lc709203f.py", line 116, in __init__
    self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 50, in __init__
    self.__probe_for_device()
  File "/usr/local/lib/python3.7/site-packages/adafruit_bus_device/i2c_device.py", line 163, in __probe_for_device
    raise ValueError("No I2C device at address: 0x%x" % self.device_address)
ValueError: No I2C device at address: 0xb

I can confirm that i2c was enabled with sudo raspi-config as soon as I had finished reinstalling Raspbian, before starting the project. Running i2cdetect -y 1 displays the following:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- 76 --     
sighmon commented 2 years ago

@jozujo Thanks again for the debugging output - I had a block of time today so managed to look at it a bit more thoroughly, as well as run it on my Pi without the solar panel and battery monitor and managed to recreate the failure.

So hopefully if you do a git pull it should work for you now. If it hasn't pulled in the right changes to the enviroplus_exporter submodule, then you can always try and run git submodule update --remote to get it to update.

Let me know how you go!

jozujo commented 2 years ago

@sighmon Although I have caused you a lot of work over the last few months, I am strangely glad that you were able to replicate my issue. But I would like to thank you so much - I have finally had success in seeing the data.

However, not all is well - it doesn't seem as though I am able to run the Dockerfile in the background (as per the instructions on the readme), only with the -d removed from docker run -d --privileged -p 8000:8000 sighmon/enviroplus_exporter:v1. Any ideas for this?

Also, I'm not sure if this is usual behaviour, but in order for it to run, is it a requirement to build and then run the Dockerfile each time?

Thanks for all your help so far!

sighmon commented 2 years ago

@jozujo That's so great it's working for you.

Re: running it in the background - what errors are you seeing?

On the Pi that isn't running Balena for remote deployment, I'm using these start/stop scripts:

# start.sh
docker run -d --name enviroplus --privileged -p 8000:8000 sighmon/enviroplus_exporter:v9
# stop.sh
cd /home/pi/Code/balena-enviro-plus
docker stop $(docker ps -aq)
docker rm enviroplus

The docker stop command stops the enviroplus container, and the docker rm command makes it so that I can re-run the container with the name enviroplus.

I wonder if the reason your background -d command isn't working is because its still half running or not completely stopped.

prutsky commented 2 years ago

Is this all fixed now? Going through the steps on the main page, results for me in simular errors. Following the above does not fix my WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v6) and no specific platform was requested error.

It's not copy paste the steps on the main page to get everything running, right?

sighmon commented 2 years ago

@prutsky The message you're seeing is a warning, and doesn't cause problems running it for me.

Could you run docker logs enviroplus and let me know what it outputs?

If you don't want to post to Influxdb or Luftdaten, change the last line of the Dockerfile to: --influxdb false --luftdaten false