awordforthat
Posts: 2
Joined: Wed Feb 04, 2015 4:05 am

PyPy with Adafruit NeoPixel library?

Wed Feb 04, 2015 5:45 pm

Hi all,

Has anyone gotten PyPy working with Adafruit's neopixel library? Please excuse my ignorance here - I'm new to most of this.

I installed the neopixel library on the RPi (B+, if it matters) according to the directions on Adafruit's site: https://learn.adafruit.com/neopixels-on ... i/software. I understand that PyPy has its own location for third-party libraries, and this is where I'm getting stuck. I copied the folder I downloaded in the first step (rpi_281x) into [pypy_directory]/lib-python as recommended by this stack overflow post: http://stackoverflow.com/questions/1119 ... ty-modules (also into [pypy_directory]/lib-python/2.7, where all the other modules seem to be). If I run a very simple program:

Code: Select all

import neopixel
print "Hello, PyPy!"
with either of these two configurations, I get back the error: "ImportError: No module named neopixel". (This works fine if I import a different module, like math. It's also fine if I run it using the standard Python 2.7 interpreter).

I also tried using pip to install the library, which that stack overflow post also mentions. Running

Code: Select all

sudo pip install neopixel 
returned the message "Could not find any downloads that satisfy the requirement neopixel. No distributions at all found for neopixel."

Is this a problem with where I'm putting the neopixel folder, or the folder name (rpi_281x vs neopixel)? Or is it because the neopixel library is ported from Arduino-land and has the Python wrapper? Or is this what it looks like when PyPy just doesn't support a module?

Any help would be much appreciated.

Thanks in advance!

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: PyPy with Adafruit NeoPixel library?

Thu Feb 05, 2015 5:04 pm

By "I copied the folder I downloaded in the first step (rpi_281x)" do you mean this

Code: Select all

git clone https://github.com/jgarff/rpi_ws281x.git
here https://learn.adafruit.com/neopixels-on ... i/software ?

Did you not run the scons build and install?

I would (without any experience with pypy but drawing parallels from regular python) assume the correct steps should be:

Code: Select all

git clone https://github.com/jgarff/rpi_ws281x.git
cd rpi_ws281x
scons
cd python
sudo pypy setup.py install
?
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

awordforthat
Posts: 2
Joined: Wed Feb 04, 2015 4:05 am

Re: PyPy with Adafruit NeoPixel library?

Sat Feb 07, 2015 12:07 am

Brilliant, thanks!

Just for my own education...do you know why the library worked properly with CPython without doing that?

User avatar
paddyg
Posts: 2555
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: PyPy with Adafruit NeoPixel library?

Sat Feb 07, 2015 2:54 pm

when you install python modules the process looks at the kind of python you are running and does slightly different things according to how they differ. The most fundamental difference is that the code will be put into different dist-packages locations (i.e.
$ sudo python setup.py install
would end up with stuff in
/usr/local/lib/python2.7/dist-packages/
and a similar process happens with python3 and pypy

pip is a kind of wrapper for doing the downloading from pypi.python.org, unzipping, doing the above command, then tidying up (and probably lots of other clever things) to get stuff for python3 you need to run pip-3.2 (or whatever it's called on the linux distribution your are using!) and there is probably a pip for pypy but I don't know if it exists on the RPi or what it's called.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

Return to “Python”