猿问

无法从“Adafruit_DHT”导入名称“Beaglebone_Black_Driver”

我在 Raspberrypi 4B 4Gb 上运行最新的树莓派操作系统“Linux raspberrypi 5.4.51-v7l+ #1327 SMP Thu Jul 23 11:04:39 BST 2020 armv7l GNU/Linux”。


我已经安装了 Python3 sudo apt-get install python3-dev python3-pip


更新了设置工具、wheel 和 pip sudo python3 -m pip install --upgrade pip setuptools wheel


并安装了 Adafruit_DHT 模块 sudo pip3 install Adafruit_DHT


之后我将我的 DHT22 连接到 gpio4 上的 rpi 并创建了以下 python 脚本:


import Adafruit_DHT

import time

from datetime import datetime


DHT_SENSOR = Adafruit_DHT.DHT22

DHT_PIN = 4

PROBE_NAME = "PI4"


humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)


if humidity is not None and temperature is not None:

    print("{2} - T={0:0.1f} H={1:0.1f}".format(temperature, humidity, datetime.now()))

else:

    print("Failed to retrieve data from humidity sensor")

比我运行它 sudo python3 temp.py


我收到以下错误


Traceback (most recent call last):

  File "temp.py", line 11, in <module>

    humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)

  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/common.py", line 94, in read_retry

    humidity, temperature = read(sensor, pin, platform)

  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/common.py", line 80, in read

    platform = get_platform()

  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/common.py", line 60, in get_platform

    from . import Beaglebone_Black

  File "/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/Beaglebone_Black.py", line 24, in <module>

    from . import Beaglebone_Black_Driver as driver

ImportError: cannot import name 'Beaglebone_Black_Driver' from 'Adafruit_DHT' (/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/__init__.py)

知道如何让它工作吗?


我在树莓派零 w 上完成了完全相同的步骤,它开箱即用


鸿蒙传说
浏览 152回答 0
0回答
随时随地看视频慕课网APP

相关分类

Python
我要回答