![](/img/trans.png)
[英]Can't install rpi_ws281x “error: command 'gcc' failed with exit status 1”
[英]isuue running rpi_ws281x(neopixels) using python on Rasberry pi 4
我已經使用以下命令在樹莓派 4b 上安裝了 ws2812 neopixels 的文件:
curl -L http://coreelec.io/33 | bash
並運行 python strandtest.py 我面臨導入錯誤
File "strandtest.py", line 9, in <module>
from rpi_ws281x import *
ImportError: No module named rpi_ws281x
盡管 rpi_ws281x 已成功安裝。 在代碼編輯器中運行相同的代碼時,模塊被正確導入並面臨其他問題
>>> %Run strandtest.py
Can't open /dev/mem: Permission denied
Traceback (most recent call last):
File "/home/pi/rpi_ws281x/python/examples/strandtest.py", line 91, in <module>
strip.begin()
File "/home/pi/.local/lib/python3.9/site-packages/rpi_ws281x/rpi_ws281x.py", line 131, in begin
raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp))
RuntimeError: ws2811_init failed with code -5 (mmap() failed)
最初,我們必須在您的 R_PI 上安裝電路 python。
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-pip
sudo pip3 install --upgrade setuptools
按照 adafruit 鏈接中的說明進行操作: https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi
然后運行示例。
adafruit 網站聲明,您需要 root 權限才能通過 rpi_ws281x 訪問 GPIO 引腳。 試試 sudo python strandtest.py
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.