[Solved] Humidity Sensor and Python

Good Afternoon and Happy Friday!

I am currently trying to work with the humidity sensor using the python matrix-lite packages. I am new to python and have more experience with js/c#/java.

I was able to get the sensors running by using this code : https://github.com/matrix-io/matrix-lite-py
My code is pretty basic

import halSwig as hal
from time import sleep

# Print exported objects/functions

## Humidity Example ##
humidity = hal.humidity()
while True:
	data = humidity.read()
	print("Humidity: ", data.humidity)
	print("Temperature: ", data.temperature)

Now what i am trying to do is take this logic and join it with the google-assistant-matrixio hotword.py logic.
When I add the below lines to the hotword.py file I get an error.

import halSwig as hal
from time import sleep

“Traceback (most recent call last):
File “/home/pi/google-assistant-matrixio/google-matrixio-assistant-hotword”, line 7, in
from matrixio.hotword import main
File “/home/pi/google-assistant-matrixio/matrixio/hotword.py”, line 29, in
import halSwig as hal
ImportError: No module named ‘halSwig’”

Why would one scrpt have no issues finding halSwig and then another script have an issue?


1 Like

hmm maybe your first code uses python3 installed with pip3 and google-assistant the older python2.7 / pip(2), or it is running in a virtual env?

python 3 should be what both were using as that is what is pre installed on this. I did install the google assistant in a virtual environment but the sensor project wasn’t.

I went back into the virtual environment and installed the matrix lite packages and everything seems to be working now.