1

我已经使用以下命令在树莓派 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)

RBI_editor

4

2 回答 2

0

最初,我们必须在您的 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

然后运行示例。

于 2021-12-17T17:07:22.770 回答
0

adafruit 网站声明,您需要 root 权限才能通过 rpi_ws281x 访问 GPIO 引脚。试试 sudo python strandtest.py

于 2021-12-22T10:27:51.513 回答