sim0nx / tsl2561 Goto Github PK
View Code? Open in Web Editor NEWPython library for Adafruit's TSL2561
License: Other
Python library for Adafruit's TSL2561
License: Other
When running the example on my RPI2 I'm getting an import error from the: from tsl2561.constants import
My error is: ImportError: No module named constants
I tried to use this library in my Raspberry Pi 3 and i had to modify a file in order to work because an error concerning future imports. I made a few changes in "tsl2561/tsl2561.py", changed the first future import for "_ future _" and deleted the second import. This is how the code looks like in my local installation:
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
'''Driver for the TSL2561 digital luminosity (light) sensors.
Pick one up at http://www.adafruit.com/products/439
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Code ported from Adafruit Arduino library,
commit ced9f731da5095988cd66158562c2fde659e0510:
https://github.com/adafruit/Adafruit_TSL2561
'''
import time
from Adafruit_GPIO import I2Cfrom
tsl2561.constants import * # pylint: disable=unused-wildcard-import
When I run the provided example on my raspberry pi 3..
from tsl2561 import TSL2561 if __name__ == "__main__": tsl = TSL2561(debug=1) print tsl.lux()
I get this error...
root@stark:/home/pi# python tsl.py
Traceback (most recent call last):
File "tsl.py", line 4, in
tsl = TSL2561(debug=1)
File "build/bdist.linux-armv7l/egg/tsl2561/tsl2561.py", line 50, in init
File "build/bdist.linux-armv7l/egg/tsl2561/tsl2561.py", line 57, in _begin
File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 148, in readU8
File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 155, in read_byte_data
IOError: [Errno 5] Input/output error
Any ideas? I have I2C enabled.
root@stark:/home/pi# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
$ python3
Python 3.6.1 (default, Mar 21 2017, 21:49:16)
[GCC 5.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tsl2561 import TSL2561
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TSL2561'
I believe the following does work:
from tsl2561.tsl2561 import TSL2561
I'm not sure, but maybe a tweak to __init__.py
would make this work in both Python 2 and 3?
pip installation gives me following error.
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 295, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 214, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 204, in clobber
os.makedirs(destdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/tsl2561-3.1.dist-info'
Storing debug log for failure in /home/pi/.pip/pip.log
pi@raspberrypi:~/tsl2561 $ pip install tsl2561
Downloading/unpacking tsl2561
Downloading tsl2561-3.1-py2.py3-none-any.whl
Installing collected packages: tsl2561
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 295, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 214, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 204, in clobber
os.makedirs(destdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/tsl2561-3.1.dist-info'
Storing debug log for failure in /home/pi/.pip/pip.log
Cloned installation gives me;
Hi,
I just installed the tsl2561 library. The install appeared to be fine, but when I triy to run the following script:
#!/usr/bin/python
from tsl2561 import TSL2561
sensor = TSL2561()
I get
rpiw$ ./lux.py
Traceback (most recent call last):
File "./lux.py", line 5, in
sensor = TSL2561()
File "build/bdist.linux-armv6l/egg/tsl2561/tsl2561.py", line 65, in init
File "build/bdist.linux-armv6l/egg/tsl2561/tsl2561.py", line 79, in _begin
File "build/bdist.linux-armv6l/egg/tsl2561/tsl2561.py", line 129, in set_integration_time
File "build/bdist.linux-armv6l/egg/tsl2561/tsl2561.py", line 88, in enable
File "build/bdist.linux-armv6l/egg/Adafruit_GPIO/I2C.py", line 114, in write8
File "build/bdist.linux-armv6l/egg/Adafruit_PureIO/smbus.py", line 236, in write_byte_data
IOError: [Errno 121] Remote I/O error
Any chance you see what's wrong? I'm running this on a raspberry pi with
rpiw$ uname -a
Linux rpiw 4.9.24+ #993 Wed Apr 26 17:56:54 BST 2017 armv6l GNU/Linux
Apologies if this is the wrong place to bring this up, but I couldn't find a forum.
The version in PYPI is still broken due to the bug I reported a few hours ago. Are you planing to upload it again in order to be able to install it via pip?
Library doesn't work with current I2C micropython implementation.
AttributeError: 'I2C' object has no attribute...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.