在Raspberry Pi上安装python的Adafruit_dht的错误400

发布于 2025-02-05 18:10:11 字数 2959 浏览 2 评论 0 原文

我需要使用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工作。提前致谢。

I need to use a DHT-11 for a school project and I am getting a weird error trying to install the packages for it.

Following the instructions I used sudo pip3 install Adafruit_DHT and that resulted in this output:

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.

I also tried running sudo pip3 install Adafruit_DHT --install-option="--force-pi" which output:

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

However, when I run my python code I get this

  import Adafruit_DHT
ModuleNotFoundError: No module named 'Adafruit_DHT'

I've updated pip and the setup tools and I'm pretty new to all of this. This assignment is due soon and I just want to get this DHT working. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

强者自强 2025-02-12 18:10:11

对我来说同样的问题。

我使用了此标志:

pip3 install Adafruit_DHT --config-settings="--build-option=--force-pi"

这是如何将参数传递给设置脚本的方法: 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:

pip3 install Adafruit_DHT --config-settings="--build-option=--force-pi"

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

妥活 2025-02-12 18:10:11

因为 - install-option =“ - force-pi” 在pip v22.3中弃用,并且因为我无法传递 - force-pi 参数使用 - config-settings (key = val格式预期)我最终使用此解决方法在安装过程中伪造PI版本:

echo '>>> Upgrade pip to at least v22.3'
python3 -m pip install --upgrade pip # upgrade pip to at least v22.3
echo '>>> Install deprecated DHT library for measurement python scripts'
# deprecated, but still used for Pi Zero WH because of known issues such as https://github.com/adafruit/Adafruit_CircuitPython_DHT/issues/73 - no longer working on bullseye
python3 -m pip install --upgrade setuptools wheel # see: https://stackoverflow.com/a/72934737/6696623
# Fake Raspberry Pi version because --install-option="--force-pi" does not work with pip v22.3
echo -e "\nHardware   : BCM2709" >> /etc/cpuinfo # see: https://github.com/adafruit/Adafruit_Python_DHT/blob/8f5e2c4d6ebba8836f6d31ec9a0c171948e3237d/Adafruit_DHT/platform_detect.py#L36
if [ -e /etc/cpuinfo ] ; then
  mount --bind /etc/cpuinfo /proc/cpuinfo
fi
pip3 install Adafruit_DHT
pip3 install Adafruit_Python_DHT

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:

echo '>>> Upgrade pip to at least v22.3'
python3 -m pip install --upgrade pip # upgrade pip to at least v22.3
echo '>>> Install deprecated DHT library for measurement python scripts'
# deprecated, but still used for Pi Zero WH because of known issues such as https://github.com/adafruit/Adafruit_CircuitPython_DHT/issues/73 - no longer working on bullseye
python3 -m pip install --upgrade setuptools wheel # see: https://stackoverflow.com/a/72934737/6696623
# Fake Raspberry Pi version because --install-option="--force-pi" does not work with pip v22.3
echo -e "\nHardware   : BCM2709" >> /etc/cpuinfo # see: https://github.com/adafruit/Adafruit_Python_DHT/blob/8f5e2c4d6ebba8836f6d31ec9a0c171948e3237d/Adafruit_DHT/platform_detect.py#L36
if [ -e /etc/cpuinfo ] ; then
  mount --bind /etc/cpuinfo /proc/cpuinfo
fi
pip3 install Adafruit_DHT
pip3 install Adafruit_Python_DHT
爺獨霸怡葒院 2025-02-12 18:10:11

当我尝试在PY上安装ADAFRUIT_DHT时,我遇到了同样的问题。

当我重新安装轮子时:

sudo python3 -m pip install --upgrade pip setuptools wheel

然后:

sudo pip3 install Adafruit_DHT

它对我有用。

I had the same problem when I tried to install the Adafruit_DHT on my py.

When I reinstalled wheel with:

sudo python3 -m pip install --upgrade pip setuptools wheel

and then:

sudo pip3 install Adafruit_DHT

it worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文