在Raspberry Pi上安装python的Adafruit_dht的错误400
我需要使用DHT-11进行学校项目,并且试图为其安装软件包时会遇到一个奇怪的错误。
按照说明我使用 sudo pip3 install adafruit_dht
,这导致了此输出:
sudo pip3 install Adafruit_DHT
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting Adafruit_DHT
Using cached Adafruit_DHT-1.4.0.tar.gz (15 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: Adafruit_DHT
Building wheel for Adafruit_DHT (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
Could not detect if running on the Raspberry Pi or Beaglebone Black. If this failure is unexpected, you can run again with --force-pi or --force-bbb parameter to force using the Raspberry Pi or Beaglebone Black respectively.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for Adafruit_DHT
Running setup.py clean for Adafruit_DHT
Failed to build Adafruit_DHT
Installing collected packages: Adafruit_DHT
Running setup.py install for Adafruit_DHT ... error
error: subprocess-exited-with-error
× Running setup.py install for Adafruit_DHT did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
Could not detect if running on the Raspberry Pi or Beaglebone Black. If this failure is unexpected, you can run again with --force-pi or --force-bbb parameter to force using the Raspberry Pi or Beaglebone Black respectively.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> Adafruit_DHT
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
我还尝试过运行 sudo pip3 install adafruit_dht -install-option =“ - forcepi-pi” - force-pi“ 哪个输出:
WARNING: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting Adafruit_DHT
Using cached Adafruit_DHT-1.4.0.tar.gz (15 kB)
Preparing metadata (setup.py) ... done
Skipping wheel build for Adafruit_DHT, due to binaries being disabled for it.
Installing collected packages: Adafruit_DHT
Running setup.py install for Adafruit_DHT ... done
Successfully installed Adafruit_DHT
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
但是,当我运行Python代码时,我得到了此信息
import Adafruit_DHT
ModuleNotFoundError: No module named 'Adafruit_DHT'
,我已经更新了PIP和设置工具,并且对所有这些都很新。这项任务即将到期,我只想让此DHT工作。提前致谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我来说同样的问题。
我使用了此标志:
这是如何将参数传递给设置脚本的方法: htttps ://github.com/pypa/pip/issues/11358#issuecomment-1493207214
这是强迫特定平台的方法:https://github.com/adafruit/Adafruit_Python_DHT/blob/8f5e2c4d6ebba8836f6d31ec9a0c171948e3237d/setup.py#L33
Same problem for me.
I used this flag:
Here is how to pass an argument to the setup script: https://github.com/pypa/pip/issues/11358#issuecomment-1493207214
Here is how to force a specific platform: https://github.com/adafruit/Adafruit_Python_DHT/blob/8f5e2c4d6ebba8836f6d31ec9a0c171948e3237d/setup.py#L33
因为
- install-option =“ - force-pi”
在pip v22.3中弃用,并且因为我无法传递- force-pi
参数使用- config-settings
(key = val格式预期)我最终使用此解决方法在安装过程中伪造PI版本:Because
--install-option="--force-pi"
is deprecated in pip v22.3 and because I was not able to pass the--force-pi
parameter using--config-settings
(KEY=VAL format expected) I ended up using this workaround to fake the Pi version during installation:当我尝试在PY上安装ADAFRUIT_DHT时,我遇到了同样的问题。
当我重新安装轮子时:
然后:
它对我有用。
I had the same problem when I tried to install the Adafruit_DHT on my py.
When I reinstalled wheel with:
and then:
it worked for me.