gpt4 book ai didi

python - 导入错误 : No module named 'board' (AdaFruit)

转载 作者:太空宇宙 更新时间:2023-11-03 11:39:13 32 4
gpt4 key购买 nike

我运行安装程序 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'

所以我不知道我做错了什么。

最佳答案

您使用 Python3 而不是 Python2 是对的。

一种解决方案 suggested here是从源代码构建 rpi_ws281x 代码。

然而,在此之前,you could try running as a super user/ administrator as suggested here.

关于python - 导入错误 : No module named 'board' (AdaFruit),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53196848/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com