Module not found with Pyodide on raspberry pi

54 views Asked by At

I'm making a website and I want to get the value of the temperature and the humidity of my house. To do this, I installed pyodide but it doesn't find the module that I want to import (Adafruit_DHT) which is essential to do what I want.

I tried to download the module with pip, to download it in the same folder of the file but it didn't work. (The python script has no problem)

Here is my code:

<html>
    <head>
        <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
        <script defer src="https://pyscript.net/unstable/pyscript.js"></script>
    </head>

    <body>


        <py-env>
            - Adafruit_DHT
        </py-env>

        <py-script src="./scripts/AdafruitDHT-a.py" output="out">

        <div id="out"></div>

    </body>
</html>

Here is my python file "AdafruitDHT-a.py":

import sys
import Adafruit_DHT

sensor = Adafruit_DHT.DHT11
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)


if humidity is not None and temperature is not None:
    print('Temp={0:0.1f}*  Humidity={1:0.1f}%'.format(temperature, humidity))
else:
    print('Failed to get reading. Try again!')
    sys.exit(1)

Here is the traceback:

Traceback (most recent call last):
  File "/home/pyodide/pyscript/_internal.py", line 104, in run_pyscript
    result = eval_code(code, globals=__main__.__dict__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 468, in eval_code
    .run(globals, locals)
     ^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/_pyodide/_base.py", line 310, in run
    coroutine = eval(self.code, globals, locals)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<exec>", line 5, in <module>
ModuleNotFoundError: No module named 'Adafruit_DHT' 

Thanks in advance.

0

There are 0 answers