shiftpi
shiftpi copied to clipboard
installation successful but module is empty
I followed the installation steps as noted but get the following and try to simply print a value in my script.
import shiftpi
print shiftpi
print shiftpi.HIGH
results in the following:
module 'shiftpi' from '/usr/local/lib/python2.7/dist-packages/shiftpi-0.2-py2.7.egg/shiftpi/init.pyc'
Traceback (most recent call last):
File "shift_register.py", line 3, in
Could this be an issue with python 2.7 incompatibility? I'd appreciate any help.
-Neil
@nvolungis @mignev I am getting the exact same issue. I hooked up shift register and and now trying the code but I cant seem to get the import statement to import the modules.
I have the import statement at the top of the file:
from shiftpi import HIGH, LOW, ALL, digitalWrite, delay
but I get the error:
pi@raspberrypi ~ $ sudo ./shiftRegister.py
Traceback (most recent call last):
File "./shiftRegister.py", line 2, in <module>
from shiftpi import HIGH, LOW, ALL, digitalWrite, delay
ImportError: cannot import name HIGH
Any clue how to fix this? I believe I am running python 2.7.
Hey @nvolungis
I was able to get the script to work! What I had to do is run the script from inside the cloned shiftpi folder. So the shiftpi.py librtary script had to be in the same directory as your custom script to control the shift register. Then it worked just fine!
@sferoze
Cool man, thanks for the info! I'll try that out.
I'm super new to Python so I may be wrong here, but shouldn't code installed via eggs be available globally? Maybe it's a problem with the install script.
Alright, I ran into the exact same problem:
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shiftpi
>>> print shiftpi
<module 'shiftpi' from 'shiftpi/__init__.py'>
>>> print shiftpi.HIGH
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'HIGH'
As you can see you imported the module shiftpi, which in this case is not the module, but the package.
So to import the actual module shiftpi of the shiftpi package just do:
>>> import shiftpi.shiftpi as shiftpi
>>> print shiftpi
<module 'shiftpi.shiftpi' from 'shiftpi/shiftpi.pyc'>
>>> print shiftpi.HIGH
1
The init file makes the folder a package. One could now either adjust the documentation or import from the init file directly, adding the following line:
from shiftpi import *
I'd be glad to help out, just let me know which method you'd prefer.
Also running
python setup.py sdist
will not build a source distribution tar, Manifest file is missing too. I'd also fix this, just let me know if this is a contribution you'd like to see.
Thanks for your work, the library really came in handy.
excuse me I am new at raspberry, can I choose just one or two pin high at the same time? I use LED for the 8 pins, can I turn on just 1 LED which we want to turn on? I try shiftpi library but the output is turning on the first, and increase... thank you