0

New with neopixels - neopixel has no atribute NeoPixel
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

New with neopixels - neopixel has no atribute NeoPixel

by klemmer on Fri Oct 04, 2019 10:00 am

Hi all,

Long time pi user but just starting out with GPIO projects. Recently bought a few Breadboard-friendly RGB Smart NeoPixels. Currently I am just hooking up ONE to a Pi Zero WH. The Pi is running off a 2amp power supply. I have the the single NeoPixel setup like this:
+ = 5v on GPIO (Pin 2)
G = Ground on GPIO (Pin 9)
I = GPIO18 (Pin 12)

I went through Adafruits instructions for setting up CircuitPython/Blinka and ran a successful test of blinkatest.py
I also followed the instructions to installing the NeoPixel library for python.

I am trying a very basic example below:
Code: Select all | TOGGLE FULL SIZE
import board
import neopixel

pixels = neopixel.NeoPixel(board.D18, 1, auto_write=False)

pixels[0] = (255, 0, 0)
pixels.show()
time.sleep(5)


and when I run this it returns the following:
Traceback (most recent call last):
File "strandtest.py", line 9, in <module>
from neopixel import *
File "/home/pi/neopixel.py", line 4, in <module>
pixels = neopixel.NeoPixel(board.D18, 1, auto_write=False)
AttributeError: module 'neopixel' has no attribute 'NeoPixel'

I also tried the strandtest.py example and I get the same exact error. I am assuming that python is not detecting that the NeoPixel is connected to the Pi?

Could it be that there is not enough power to run a single NeoPixel? Or perhaps this NeoPixel is bad? Or maybe I did not solder it/connect it correctly? I am out of ideas so any help would be very much appreciated!

Thanks!

klemmer
 
Posts: 2
Joined: Fri Oct 04, 2019 8:49 am

Re: New with neopixels - neopixel has no atribute NeoPixel

by dastels on Fri Oct 04, 2019 10:25 am

Is the code you posed in /home/pi/neopixel.py? That could be confusing CP since the neopixel library is neopixel.py. If so then it looks like it's trying to import *your* neopixel.py (not the one from the bundle) and not finding NeoPixel since it isn't defined there.

dastels
 
Posts: 454
Joined: Tue Oct 20, 2015 3:22 pm

Re: New with neopixels - neopixel has no atribute NeoPixel

by klemmer on Fri Oct 04, 2019 11:04 am

Thank you so much!! That is exactly what I did. I just renamed neopixel.py to something else and boom it worked!!!

klemmer
 
Posts: 2
Joined: Fri Oct 04, 2019 8:49 am

Please be positive and constructive with your questions and comments.