在树莓派上找不到带有 Pyodide 的模块

Module not found with Pyodide on raspberry pi

提问人:Marcucus _ 提问时间:11/3/2023 最后编辑:journpyMarcucus _ 更新时间:11/4/2023 访问量:24

问:

我正在制作一个网站,我想获得我家的温度和湿度的值。 为此,我安装了pyodide,但它没有找到我想导入的模块(Adafruit_DHT),这对于做我想做的事情是必不可少的。

我尝试用pip下载模块,将其下载到文件的同一文件夹中,但没有用。 (python脚本没有问题)

这是我的代码:

<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>

这是我的 python 文件“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)

以下是回溯:

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' 

提前致谢。

python html 树莓派 pi3 pyodide

评论


答: 暂无答案