Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'board' (AdaFruit)

I run the setup from this website to get my arduino to use AdaFruit LEDs. And also run:

sudo pip3 install adafruit-circuitpython-neopixel

I then made this python code:

import board
import neopixel
pixels = neopixel.NeoPixel(board.D18, 12, brightness=0.2)
pixels[0] = (255, 0, 0)

And then executed it with python filename.py And got the error:

ImportError: No module named 'board'

I then thought I maybe need to use python3 (Because it every where says too)

So I typed:

python3 light-test.py

This time got some more output, but in the end again an 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'

So I don't know know what I am doing wrong.

like image 964
Timothy Lukas H. Avatar asked Nov 07 '18 19:11

Timothy Lukas H.


2 Answers

You're right to use Python3 instead of Python2.

One solution suggested here is to build the rpi_ws281x code from source.

Before that, however, you could try running as a super user/ administrator as suggested here.

like image 110
jarcobi889 Avatar answered Sep 17 '22 20:09

jarcobi889


If you're missing the 'board' module, that gets installed with the following pip3 command:

sudo pip3 install adafruit-blinka

like image 27
ConcernedHobbit Avatar answered Sep 20 '22 20:09

ConcernedHobbit