# Enviro+ issue: python and python 3

**URL:** https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181
**Category:** Support
**Created:** [March 1, 2020, 2:54pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181 "2020-03-01T14:54:07Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![MelanieF](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MelanieF](https://forums.pimoroni.com/u/MelanieF)
#### Post date: [March 1, 2020, 2:54pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/1 "2020-03-01T14:54:07Z")

</div>

Hi

I am a relatively novice user and am currently trying to set up my Enviro+.

I have had problems with installing bme280. Following the “Getting started article” on Pimoroni for the enviro+ seemed to install everything but I encountered an error when running the all-in-one.py script  
from bme280 import BME280  
Traceback (most recent call last):  
File “”, line 1, in   
ImportError: cannot import name BME280

I have researched the error and uninstalled enviroplus from the pi. Then reinstalled it using the curl install mentioned on this forum. I also installed the libraries to Python3.

What I have come to realise is that the line of code “from bme280 import BME280” runs fine from the Python3 shell, but not from the Python shell. I cannot run the enviroplus python code from a Python3 shell as it is not formatted correctly.

Could anyone provide further guidance on getting the bme280 libraries running. The module is definitely installed on the Pi.

Thank you

---

<div class="post-metadata">

### Author: ![nophead](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nophead/32/5827_2.png) [@nophead](https://forums.pimoroni.com/u/nophead)
#### Post date: [March 1, 2020, 9:22pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/2 "2020-03-01T21:22:18Z")

</div>

Do you want to use Python2 or Python3?

I use Python3 for everything as Python2 went end of life in January. To install things for Python3 I use pip3 instead of pip.

I use the bme280 library from Python3 without problems. When you say the examples aren’t formatted correctly for Python3 can you be more specific. It should be an easy fix.

---

<div class="post-metadata">

### Author: ![MelanieF](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MelanieF](https://forums.pimoroni.com/u/MelanieF)
#### Post date: [March 1, 2020, 9:44pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/3 "2020-03-01T21:44:45Z")

</div>

Thanks for the reply. Yep I agree Python 3 makes sense.

I am referring to the example python scripts that pimoroni supply for the enviro+ board. There are several very useful scripts that enable readings from the sensors to display on the LED screen.

I guess I may need to reformat them into python 3 scripts as they are currently python 2. Unless I can get the bme280 library working

---

<div class="post-metadata">

### Author: ![nophead](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nophead/32/5827_2.png) [@nophead](https://forums.pimoroni.com/u/nophead)
#### Post date: [March 1, 2020, 9:57pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/4 "2020-03-01T21:57:52Z")

</div>

IIRC I had to change a lot of divides from / to // to make the examples work in Python3. I think 2 always produces an integer when two integers are divided by 3 produces a fraction so // has to be used to force an integer result like 2.

---

<div class="post-metadata">

### Author: ![MelanieF](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MelanieF](https://forums.pimoroni.com/u/MelanieF)
#### Post date: [March 1, 2020, 10:26pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/5 "2020-03-01T22:26:05Z")

</div>

Still wondering why the bme280 line of code  
From bme20 import BME280

Won’t run in python 2. As this is what is suggested in the enviro+ tutorial.

---

<div class="post-metadata">

### Author: ![nophead](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nophead/32/5827_2.png) [@nophead](https://forums.pimoroni.com/u/nophead)
#### Post date: [March 1, 2020, 10:50pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/6 "2020-03-01T22:50:44Z")

</div>

If you type

` pip2 list | grep bme`

do you get something like

`pimoroni-bme280 0.0.1`

---

<div class="post-metadata">

### Author: ![MelanieF](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MelanieF](https://forums.pimoroni.com/u/MelanieF)
#### Post date: [March 2, 2020, 5:44pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/7 "2020-03-02T17:44:06Z")

</div>

Yep, I get  
bme 280 0.5  
pimoroni-bme280 0.0.2

---

<div class="post-metadata">

### Author: ![nophead](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nophead/32/5827_2.png) [@nophead](https://forums.pimoroni.com/u/nophead)
#### Post date: [March 2, 2020, 8:02pm UTC](https://forums.pimoroni.com/t/enviro-issue-python-and-python-3/13181/8 "2020-03-02T20:02:27Z")

</div>

Looks like you have two bme280 libraries installed. Perhaps the non-pimoroni one doesn’t have the BME280 constructor. You could try

`pip2 uninstall bme280`

Also I noticed that the pimoroni github for the Enviro+ was updated for Python3 today.
