'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.



Solution 1:[1]

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.

Solution 2:[2]

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

sudo pip3 install adafruit-blinka

Solution 3:[3]

I found that there was a board module already installed on my system (the wrong one). I deleted the board module and reinstalled adafruit-blinka to fix this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jarcobi889
Solution 2
Solution 3 Mainmeister