**mars@raspberrypi**:**~/Desktop $** python
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from envirophat import light
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/dist-packages/envirophat/__init__.py", line 1, in <module>
from .i2c_bus import bus
File "/usr/local/lib/python3.9/dist-packages/envirophat/i2c_bus.py", line 20, in <module>
bus = smbus.SMBus(1)
FileNotFoundError: [Errno 2] No such file or directory
>>>
I already ran:
curl https://get.pimoroni.com/envirophat | bash
and got the All done. Enjoy your Enviro pHAT! message after install.
Yeah, that install command | bash, ive run before. I just ran it again and I even see this:
Checking environment...
Updating apt indexes...
.....................
Checking hardware requirements...
Checking for packages required for GPIO control...
raspi-gpio is already installed
RPi.GPIO installed and up-to-date
I2C already enabled
Checking packages required by I2C interface...
Python 2 smbus installed and up-to-date
Python 3 smbus installed and up-to-date
Enviro pHAT comes with examples and documentation that you may wish to install.
Performing a full install will ensure those resources are installed,
along with all required dependencies. It may however take a while!
Do you wish to perform a full install? [y/N]
which is telling me that the. smbus for python3 are up to date.
I tried the manual install, same problem…
I had this code on an rpi0 and I noticed one of the files on the desktop called shenviro.sh:
i think i had some other code running the actual script (which is envirophat2.py) but I just cant remember. Maybe it had something to do with creating an environment for it to run in?
There are other commands you can run, other than the curl command. Go down the page a little and it lists them. It does the equivalent of the curl command, but with much more manual steps.
sudo’ing all those installs won’t install them into your python virtenv; try the pip3 flavour without the sudo, while running in your virtenv - that should then get installed in the right place.
My bad; I’d blurred two different threads - ENOENT on SMBus would normally indicate that you haven’t got your i2c enabled, but the script output further up implies that that’s already done.
YES! Thank you so much! I got it to work and i was able to run my python file and log data to my thingspeak account. Unfortunately, the water damage that killed by rpi0, seems to have damaged the envirophat board as well and most readings came back with value 0.
the temperature value was one of only ones that came back with non-zero values. So i guess I have to get a new hat.
In the meantime, could I bother to ask how i can view my rpi0 crontab or the other files that are normally used to start up jobs in rpi automatically? The way i had it running on my rpi0 is that it would log data every 5 minutes i believe. And even with power outs, which are frequent, it would resume logging as soon as power was restored and it rebooted. Im leaning towards crontab but it could be rc.local. I have my old rpi0 sd card in a usb port on my new rpi so i just need to know where to look…
I looked in rc.local and .bashrc and init.d directory and /etc/crontab/ but. didnt find anything.
I did notice i had a file on the desktop along with the actual python script called shenviro.sh which contains. this:
FOUND IT. Its tricky navigating another drive on linux if you dont use absolute paths. I was checking my rpi directories instead of the usb-sd card one.