gpt4 book ai didi

python - 无法从 'Beaglebone_Black_Driver' 导入名称 'Adafruit_DHT'

转载 作者:行者123 更新时间:2023-12-03 09:51:48 27 4
gpt4 key购买 nike

我在 Raspberrypi 4B 4Gb 上运行最新的树莓派操作系统“Linux raspberrypi 5.4.51-v7l+ #1327 SMP Thu Jul 23 11:04:39 BST 2020 armv7l GNU/Linux”。
我已经安装了 Python3sudo apt-get install python3-dev python3-pip更新了 setuptools、wheel 和 pipsudo 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 上完成了完全相同的步骤,它开箱即用

最佳答案

在“/usr/local/lib/python3.7/dist-packages/Adafruit_DHT/platform_detect.py”中,
您可以在 elif 阶梯的第 112 行添加以下内容,因此它应该可以解决该问题。

elif match.group(1) == 'BCM2711':
return 3
由于最近的 raspbian 升级,/proc/cpuinfo 中的硬件名称似乎已更改。

关于python - 无法从 'Beaglebone_Black_Driver' 导入名称 'Adafruit_DHT',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63232072/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com