ImportError: No module named bme280

Fresh install of the latest PiOS on a Pi Zero W.
pHat Stack with Breakout Garden Mini i2c SPI and Mini i2c
BME280, RV3028, LTR-599 in the mini i2c BG
0.96 SPI Color LCD in the mini i2c SPI BG

The BME280 is giving me the following error when I run the all-values.py file. Either from thoony or via command line.

from bme280 import BME280
ImportError: No module named bme280

i2c is enabled and I have run the following.
sudo pip install pimoroni-bme280 smbus
sudo pip3 install pimoroni-bme280 smbus
and also did the following
git clone https://github.com/pimoroni/bme280-python
cd bme280-python
sudo ./install.sh
and rebooted several times.
Tried two different BME280’s, one that was working before I reimaged my SD card, and one new one I just received today. Both give the above error.

@Matt

Looks like I got a messed up RV3028 RTC in that order. Battery was inserted reversed? Flipped it around the correct way but it still wouldn’t keep the correct time. Checked the battery and it was dead. I swapped a good one from a working RV3028 but it still won’t work? After swapping the battery back into the other working RV3028, and swapping it in place of the one that’s not working I have a working RTC so the software install was fine. BME280 still won’t work though?
The LTR-599 in the mini i2c BG worked OK.
As did the 0.96 SPI Color LCD in the i2c SPI mini BG.

I’m having the same problem. Raspberry pi 4, default raspberry pi os install. I get the bme280 module not found error. Otherwise, the lcd works and the light sensor works.

Try running this from terminal.
pip install pimoroni-bme280==0.0.2
It got mine working. It was posted to an issue I opened on this on GitHub.
The ==0.0.2 installs the older version 0.0.2. The newer 0.1.0 is the one with the issue.

This worked for me too, thanks for the tip.

Perhaps Pimoroni could update the instructions on the Github page for the library? It has been 2 years!

Not an issue anymore as far as I know? I have several BME280’s on the go here, on Pi’s and Pico’s, no problems with import errors here?.

Well, just speaking as someone who bought a BME280 board from Pimoroni and followed the instructions for installing the library.

Ok, when I get a chance I’ll plug one of mine into my Breakout Garden Hat and run the installer. Maybe they broke it again?
What version of Pi OS are you running?
Did you run
sudo pip install pimoroni-bme280 smbus
or
sudo pip3 install pimoroni-bme280 smbus

To be honest, I don’t know what version of the OS I have? I’ve had the Pi for 3 years or so and it’s the one that came with it - is there a way to check please?

I’m using Python 3.x, and used the “pip3” command.

from terminal run cat /etc/os-release

pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME=“Raspbian GNU/Linux 11 (bullseye)”
NAME=“Raspbian GNU/Linux”
VERSION_ID=“11”
VERSION=“11 (bullseye)”
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL=“http://www.raspbian.org/
SUPPORT_URL=“RaspbianForums - Raspbian
BUG_REPORT_URL=“RaspbianBugs - Raspbian

Going to do some testing today. Had to hunt up the hardware I needed. Just flashed a spare SD Card with the latest Pi OS. Pi Zero, Hat Hacker, Breakout garden Hat, and BME280.

Ok, booted up my Pi Zero 2 and ran
sudo pip install pimoroni-bme280 smbus
and
sudo pip3 install pimoroni-bme280 smbus
Rebooted that Pi and ran the all values example. No errors.

#!/usr/bin/env python

import time
try:
    from smbus2 import SMBus
except ImportError:
    from smbus import SMBus
from bme280 import BME280



print("""all-values.py - Read temperature, pressure, and humidity

Press Ctrl+C to exit!

""")


# Initialise the BME280
bus = SMBus(1)

bme280 = BME280(i2c_dev=bus)

while True:
    temperature = bme280.get_temperature()
    pressure = bme280.get_pressure()
    humidity = bme280.get_humidity()
    print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity))
    time.sleep(1)