Problem installing Enviro software on Pi zero

Hi
I am having problems getting my Enviro to work with a Pi Zero WH which appears to otherwise work OK.
I have used a new up to date installation of Symbian and followed your instructions for installing the software for the Enviro but this throws up a number of errors.
Trying to run the Python demo program weather.py and other demos fail with the following message

pi@raspberrypi:~/enviroplus-python/examples ls adc.py gas.py noise-amps-at-freqs.py all-in-one-no-pm.py icons noise-profile.py all-in-one.py lcd.py particulates.py combined.py light.py weather-and-light.py compensated-temperature.py luftdaten.py weather.py pi@raspberrypi:~/enviroplus-python/examples python weather.py
Traceback (most recent call last):
File “weather.py”, line 4, in
from bme280 import BME280
File “/usr/local/lib/python2.7/dist-packages/pimoroni_bme280-0.0.2-py2.7.egg/bme280/init.py”, line 2, in
from i2cdevice import Device, Register, BitField, _int_to_bytes
ImportError: No module named i2cdevice

I would be grateful for any help.
The error messages generated during installation of the Enviro software follow

pi@raspberrypi:~ git clone https://github.com/pimoroni/enviroplus-python Cloning into 'enviroplus-python'... remote: Enumerating objects: 15, done. remote: Counting objects: 100% (15/15), done. remote: Compressing objects: 100% (13/13), done. remote: Total 577 (delta 2), reused 7 (delta 2), pack-reused 562 Receiving objects: 100% (577/577), 358.34 KiB | 661.00 KiB/s, done. Resolving deltas: 100% (358/358), done. pi@raspberrypi:~ cd enviroplus-python
pi@raspberrypi:~/enviroplus-python pi@raspberrypi:~/enviroplus-python sudo ./install.sh
Checking for python-configparser
enviroplus 0.0.3 Python Library: Installer

Installing for Python 2…
Checking for python-pip
Checking for python-numpy
Checking for python-smbus
Checking for python-pil
Checking for python-spidev
Checking for python-rpi.gpio
Checking for libportaudio2
zip_safe flag not set; analyzing archive contents…
package init file ‘src/doc/init.py’ not found (or not a regular file)
package init file ‘src/test/init.py’ not found (or not a regular file)
File “build/bdist.linux-armv6l/egg/astral/geocoder.py”, line 428
def database() -> LocationDatabase:
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/astral/main.py”, line 38
kwargs: Dict[str, Any] = {}
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/astral/location.py”, line 23
def init(self, info: Optional[LocationInfo] = None):
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/astral/moon.py”, line 11
def _phase_asfloat(date: datetime.date) -> float:
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/astral/init.py”, line 78
def now(tzinfo: datetime.tzinfo = pytz.utc) -> datetime.datetime:
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/astral/sun.py”, line 47
def proper_angle(value: float) -> float:
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/test/almost_equal.py”, line 6
def datetime_almost_equal(datetime1: datetime, datetime2: datetime, seconds: int = 60):
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/test/test_norway.py”, line 10
def _next_event(obs: astral.Observer, dt: datetime, event: str):
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/test/test_sun_calc.py”, line 18
def test_JulianDay(day: datetime.date, jd: float):
^
SyntaxError: invalid syntax

File “build/bdist.linux-armv6l/egg/test/conftest.py”, line 9
def test_database() -> LocationDatabase:
^
SyntaxError: invalid syntax

zip_safe flag not set; analyzing archive contents…
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing libffi.pc' to the PKG_CONFIG_PATH environment variable No package 'libffi' found Package libffi was not found in the pkg-config search path. Perhaps you should add the directory containing libffi.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘libffi’ found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing libffi.pc' to the PKG_CONFIG_PATH environment variable No package 'libffi' found Package libffi was not found in the pkg-config search path. Perhaps you should add the directory containing libffi.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘libffi’ found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing libffi.pc' to the PKG_CONFIG_PATH environment variable No package 'libffi' found c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory #include <ffi.h> ^~~~~~~ compilation terminated. error: Setup script exited with error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1 Installing for Python 3.. Checking for python3-pip Checking for python3-numpy Checking for python3-smbus Checking for python3-pil Checking for python3-spidev Checking for python3-rpi.gpio Checking for libportaudio2 zip_safe flag not set; analyzing archive contents... Package libffi was not found in the pkg-config search path. Perhaps you should add the directory containing libffi.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘libffi’ found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing libffi.pc' to the PKG_CONFIG_PATH environment variable No package 'libffi' found Package libffi was not found in the pkg-config search path. Perhaps you should add the directory containing libffi.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘libffi’ found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing libffi.pc' to the PKG_CONFIG_PATH environment variable No package 'libffi' found Package libffi was not found in the pkg-config search path. Perhaps you should add the directory containing libffi.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘libffi’ found
c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^~~~~~~
compilation terminated.
error: Setup script exited with error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1
Setting up i2c and SPI…
Backing up /boot/config.txt to /boot/config.preinstall-enviroplus-2020-38-04-15-38-36.txt

Setting up serial for PMS5003…
Adding dtoverlay=pi3-miniuart-bt to /boot/config.txt

Sorry that should be Raspian not Symbian !

I am having the same issue. I get the error on both weather.py and light.py on a Pi zero W and Raspbian Lite. I didn’t see anything about the I2cdevice in the boot log.

Raspbian Lite is missing some things that the “With Desktop” version has by default.

I have tried with both Raspian Lite and the full version with all the extras. I get the same error messages with both.

Ok, I wasn’t sure if Lite was being used or if it might be the issue but I figured I better mention it as a “possible” issue.

You could try running the following, just in case there is a missing dependency
sudo apt install python-numpy python-smbus python-pil python-setuptools
and for python 3
sudo apt install python3-numpy python3-smbus python3-pil python3-setuptools

Unfortunately that does not seem to have helped. Both commands reported that all were the newest version and nothing new was installed.

I’m kind of grasping at straws but if you did the curl bash install try this instead

git clone https://github.com/pimoroni/enviroplus-python
cd enviroplus-python
sudo ./install.sh

I have tried both methods of installation with similar results. I get a series of error messages which endwith the following

No package ‘libffi’ found
c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^~~~~~~
compilation terminated.
error: Setup script exited with error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1
Setting up i2c and SPI…

although it then appears to finish normally.
I cannot see any reference to i2cdevice in the error messages

I have also run a simple python test and do see the I2c active:

#!/usr/bin/env python

import smbus

bus = smbus.SMBus(1) # 1 indicates /dev/i2c-1

for device in range(128):

  try:
     bus.read_byte(device)
     print(hex(device))
  except: # exception if read_byte fails
     pass

python3 i2ctest.py
0x23
0x49
0x76

I have tried the same and only get 0x23 & 0x76
but I presume that is because I have an Enviro not an Enviro+ so fewer sensors.

My search for libffi took me here, not sure if it helps though.

i2cdetect -y 1 is what you can run from terminal.

For the + it’s
0x49: ADS1015
0x76: BME280
0x23: LTR559

I had a look at it and found it all a bit beyond my skill level but it may provide some help.

One thing you can do is report this on Pimoroni’s GitHub Page for the Enviro / Enviro+, in the issues section.

Running i2c detect is a nice quick way to see if its working. If its not turned on / enabled you’ll get an error as soon as you run it. Then see what you get. All zero’s or all the fields full are an indication of an issue.
As far as i2c goes, its a shared bus and can have multiple devices connected. You just can’t have two devices with the same address. Do that an neither one of them will work.

Many thanks for your help. I have finally got it working by installing the missing libffi module with

sudo apt-get install libffi-dev

having done that the enviroplus-python package installs without any error messages and after rebooting the demo programmes run as expected.

1 Like

That’s good to hear.

Best guess is the owner of the libffi repository has moved things around or changed something that has broken the Pimoroni installer.

Hi all. I’m struggling with this on my new enviro and enviro+ .

Have you found any way forward to get these working?

Thanks.

He did get his working, he says as much in his last post.
Start at the top and work down and see if anything posted helps.