我运行设置from this website来让我的arduino使用AdaFruit LED。 并运行:
sudo pip3 install adafruit-circuitpython-neopixel
然后我编写了以下python代码:
import board
import neopixel
pixels = neopixel.NeoPixel(board.D18, 12, brightness=0.2)
pixels[0] = (255, 0, 0)
然后使用python filename.py
执行它
并得到错误:
ImportError: No module named 'board'
然后我以为我可能需要使用python3(因为每个地方都说过)
所以我输入:
python3 light-test.py
这一次得到了更多输出,但最后还是再次出现ImportError:
File "light-test.py", line 2, in <module>
import neopixel
File "/usr/local/lib/python3.5/dist-packages/neopixel.py", line 34, in
<module>
from neopixel_write import neopixel_write
File "/home/pi/.local/lib/python3.5/site-packages/neopixel_write.py", line
15, in <module>
from adafruit_blinka.microcontroller.raspi_23 import neopixel as _neopixel
File "/home/pi/.local/lib/python3.5/site-
packages/adafruit_blinka/microcontroller/raspi_23/neopixel.py", line 3, in
<module>
import _rpi_ws281x as ws
ImportError: No module named '_rpi_ws281x'
所以我不知道我在做什么错。有想法吗?
谢谢!
答案 0 :(得分:1)
您正确使用Python3而不是Python2。
一种解决方案suggested here是从源代码构建rpi_ws281x代码。
在此之前,you could try running as a super user/ administrator as suggested here.
答案 1 :(得分:0)
如果您缺少'board'模块,则可以使用以下pip3命令进行安装:
sudo pip3 install adafruit-blinka