在 Raspberry pi 4 上使用 python 发出 运行 rpi_ws281x(neopixels)
isuue running rpi_ws281x(neopixels) using python on Rasberry pi 4
我已经在 raspberry pi 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 link 中的说明进行操作:
https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi
然后是运行例子。
adafruit 网站指出,您需要 root 权限才能通过 rpi_ws281x 访问 GPIO 引脚。试试 sudo python strandtest.py
我已经在 raspberry pi 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 link 中的说明进行操作: https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi
然后是运行例子。
adafruit 网站指出,您需要 root 权限才能通过 rpi_ws281x 访问 GPIO 引脚。试试 sudo python strandtest.py