Downloaded setup from instructions in:
https://pypi.python.org/pypi/max7219
After downloading I then try to install w/ the following code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import os
import sys
from io import open
from setuptools import setup
def read_file(fname, encoding='utf-8'):
with open(fname, encoding=encoding) as r:
return r.read()
def find_version(*file_paths):
fpath = os.path.join(os.path.dirname(__file__), *file_paths)
version_file = read_file(fpath)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
err_msg = 'Unable to find version string in {}'.format(fpath)
raise RuntimeError(err_msg)
README = read_file('README.rst')
CONTRIB = read_file('CONTRIBUTING.rst')
CHANGES = read_file('CHANGES.rst')
version = find_version('luma', 'led_matrix', '__init__.py')
print( version )
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []
test_deps = [
'mock;python_version<"3.3"',
'pytest>=3.1',
'pytest-cov'
]
setup(
name="luma.led_matrix",
version=version,
author="Richard Hull",
author_email="
[email protected]",
description="A library to drive a MAX7219 LED serializer (using SPI) and WS2812 NeoPixels (using DMA)",
long_description="\n\n".join([README, CONTRIB, CHANGES]),
license="MIT",
keywords=["raspberry pi", "rpi", "led", "max7219", "matrix", "seven segment", "7 segment", "neopixel", "ws2812", "ws281x"],
url="
https://github.com/rm-hull/luma.led_matrix",
download_url="
https://github.com/rm-hull/luma.led_matrix/tarball/" + version,
namespace_packages=["luma"],
packages=["luma.led_matrix"],
install_requires=["luma.core>=1.2.1"],
setup_requires=pytest_runner,
tests_require=test_deps,
extras_require={
':platform_machine=="armv7l" and platform_system=="Linux"': [
'ws2812', 'rpi_ws281x'
],
'docs': [
'sphinx >= 1.5.1'
],
'qa': [
'rstcheck',
'flake8'
],
'test': test_deps
},
zip_safe=False,
classifiers=[
"License :: OSI Approved :: MIT License",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Education",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Education",
"Topic :: System :: Hardware",
"Topic :: System :: Hardware :: Hardware Drivers",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Operating System :: POSIX",
"Operating System :: Unix"
]
)
Actually got around the initial problem of test_requires by reverting to Python3. However, there is still a problem w/ setup:
no previously-included directories found matching 'doc/_build'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
warning: no previously-included files matching '*~' found under directory '*'
warning: no previously-included files matching '.coverage' found under directory '*'
warning: no previously-included files matching '.DS_Store' found under directory '*'
warning: no previously-included files matching '.ropeproject' found under directory '*'
warning: no files found matching '*.c'
warning: no files found matching '*.h'
warning: no files found matching '*.sh'
no previously-included directories found matching 'docs/_static'
warning: no previously-included files found matching '.appveyor.yml'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.codecov.yml'
warning: no previously-included files found matching '.editorconfig'
warning: no previously-included files found matching '.landscape.yaml'
warning: no previously-included files found matching '.travis'
warning: no previously-included files found matching '.travis/*'
warning: no previously-included files found matching 'build_children.sh'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest ... ation.html
Traceback (most recent call last):
File "/tmp/easy_install-8cad5kkg/Pillow-5.1.0/setup.py", line 794, in <module>
File "/usr/local/lib/python3.4/dist-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/bdist_egg.py", line 172, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/bdist_egg.py", line 158, in call_command
self.run_command(cmdname)
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/install_lib.py", line 11, in run
self.build()
File "/usr/lib/python3.4/distutils/command/install_lib.py", line 109, in build
self.run_command('build_ext')
File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.4/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/easy_install-8cad5kkg/Pillow-5.1.0/setup.py", line 582, in build_extensions
__main__.RequiredDependencyException: jpeg
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-8cad5kkg/Pillow-5.1.0/setup.py", line 806, in <module>
__main__.RequiredDependencyException:
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest ... ation.html
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./setup3.py", line 88, in <module>
"Operating System :: Unix"
File "/usr/local/lib/python3.4/dist-packages/setuptools/__init__.py", line 129, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/install.py", line 117, in do_egg_install
cmd.run()
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 412, in run
self.easy_install(spec, not self.no_deps)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 654, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 701, in install_item
self.process_distribution(spec, dist, deps)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 746, in process_distribution
[requirement], self.local_index, self.easy_install
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 774, in resolve
replace_conflicting=replace_conflicting
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 1057, in best_match
return self.obtain(req, installer)
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 1069, in obtain
return installer(requirement)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 673, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 699, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 884, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 1152, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/local/lib/python3.4/dist-packages/setuptools/command/easy_install.py", line 1138, in run_setup
run_setup(setup_script, args)
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 253, in run_setup
raise
File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 166, in save_modules
saved_exc.resume()
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 141, in resume
six.reraise(type, exc, self._tb)
File "/usr/local/lib/python3.4/dist-packages/setuptools/_vendor/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/usr/local/lib/python3.4/dist-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-8cad5kkg/Pillow-5.1.0/setup.py", line 806, in <module>
setuptools.sandbox.UnpickleableException: RequiredDependencyException('\n\nThe headers or library files could not be found for jpeg,\na required dependency when compiling Pillow from source.\n\nPlease see the install instructions at:\n
https://pillow.readthedocs.io/en/latest ... n.html\n\n',)
When I try any of the examples I get the msg that it cannot find the module luma.led_matrix.device
but it does exist in /luma/led_matrix as device.py
example is as follows:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.rst for details.
import re
import time
import argparse
from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import viewport
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT
def demo(n, block_orientation, rotate):
# create matrix device
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, cascaded=n or 1, block_orientation=block_orientation, rotate=rotate or 0)
print("Created device")
# start demo
msg = "MAX7219 LED Matrix Demo"
print(msg)
show_message(device, msg, fill="white", font=proportional(CP437_FONT))
time.sleep(1)
msg = "Fast scrolling: Lorem ipsum dolor sit amet, consectetur adipiscing\
elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut\
enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in\
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit\
anim id est laborum."
msg = re.sub(" +", " ", msg)
print(msg)
show_message(device, msg, fill="white", font=proportional(LCD_FONT), scroll_delay=0)
msg = "Slow scrolling: The quick brown fox jumps over the lazy dog"
print(msg)
show_message(device, msg, fill="white", font=proportional(LCD_FONT), scroll_delay=0.1)
print("Vertical scrolling")
words = [
"Victor", "Echo", "Romeo", "Tango", "India", "Charlie", "Alpha",
"Lima", " ", "Sierra", "Charlie", "Romeo", "Oscar", "Lima", "Lima",
"India", "November", "Golf", " "
]
virtual = viewport(device, width=device.width, height=len(words) * 8)
with canvas(virtual) as draw:
for i, word in enumerate(words):
text(draw, (0, i * 8), word, fill="white", font=proportional(CP437_FONT))
for i in range(virtual.height - device.height):
virtual.set_position((0, i))
time.sleep(0.05)
msg = "Brightness"
print(msg)
show_message(device, msg, fill="white")
time.sleep(1)
with canvas(device) as draw:
text(draw, (0, 0), "A", fill="white")
time.sleep(1)
for _ in range(5):
for intensity in range(16):
device.contrast(intensity * 16)
time.sleep(0.1)
device.contrast(0x80)
time.sleep(1)
msg = "Alternative font!"
print(msg)
show_message(device, msg, fill="white", font=SINCLAIR_FONT)
time.sleep(1)
msg = "Proportional font - characters are squeezed together!"
print(msg)
show_message(device, msg, fill="white", font=proportional(SINCLAIR_FONT))
#
http://www.squaregear.net/fonts/tiny.shtml
time.sleep(1)
msg = "Tiny is, I believe, the smallest possible font \
(in pixel size). It stands at a lofty four pixels \
tall (five if you count descenders), yet it still \
contains all the printable ASCII characters."
msg = re.sub(" +", " ", msg)
print(msg)
show_message(device, msg, fill="white", font=proportional(TINY_FONT))
time.sleep(1)
msg = "CP437 Characters"
print(msg)
show_message(device, msg)
time.sleep(1)
for x in range(256):
with canvas(device) as draw:
text(draw, (0, 0), chr(x), fill="white")
time.sleep(0.1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='matrix_demo arguments',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--cascaded', '-n', type=int, default=1, help='Number of cascaded MAX7219 LED matrices')
parser.add_argument('--block-orientation', type=int, default=0, choices=[0, 90, -90], help='Corrects block orientation when wired vertically')
parser.add_argument('--rotate', type=int, default=0, choices=[0, 1, 2, 3], help='Rotate display 0=0°, 1=90°, 2=180°, 3=270°')
args = parser.parse_args()
try:
demo(args.cascaded, args.block_orientation, args.rotate)
except KeyboardInterrupt:
pass
Exact error is:
Traceback (most recent call last):
File "examples/matrix_demo.py", line 10, in <module>
from luma.led_matrix.device import max7219
ImportError: No module named 'luma.led_matrix'
Still stumped and hoping for more advice/suggestions. Thx.