Page 1 of 1

Using 7 segment display inside Python code

Posted: Wed May 29, 2019 8:39 pm
by Daveolw1
Using a 8 digit 7 segment Max7219 display module and want to access it fro my python code by pressing buttons to change the display characters. It works when running from terminal SUDO, but from python I get an error,

"from luma.led_matrix.device import max7219
ImportError: No module named 'luma'"

I believe this is something to with root access although spi is in the 99.com file so it should work.
Any ides how to solve?

David

Re: Using 7 segment display inside Python code

Posted: Wed May 29, 2019 9:04 pm
by MrYsLab
It appears you did not install the library properly. You can find detailed install instructions here: https://luma-led-matrix.readthedocs.io/en/latest/

Re: Using 7 segment display inside Python code

Posted: Wed May 29, 2019 9:41 pm
by Andyroo
Bit baffled by the OP post :oops:

How do you run it from the terminal as sudo - is it a python program?

If not what program are you running to display things on the segments?

Re: Using 7 segment display inside Python code

Posted: Thu May 30, 2019 6:36 am
by Daveolw1
Yes I followed those instructions and did the checks to confirm it had everything installed.
Yes it is Python as stated in my post.

Re: Using 7 segment display inside Python code

Posted: Thu May 30, 2019 6:51 am
by ghp
Common problem is that the own python program has same name as an import. In your case, is your file named luma.py ? Then rename it and retry.

Re: Using 7 segment display inside Python code

Posted: Thu May 30, 2019 2:21 pm
by Daveolw1
No name is "test7seg.py"

Re: Using 7 segment display inside Python code

Posted: Thu May 30, 2019 3:38 pm
by DougieLawson
Did you install with pip (python2) or pip3 (python3)?
Are you running with python (aka python2) or python3?

Re: Using 7 segment display inside Python code

Posted: Thu May 30, 2019 3:39 pm
by ghp
Is it a python2-python3 problem? When installing with 'pip', the library goes into the python==python2 modules collection. When starting the application code then with python3, the library is not found.

Install with 'pip' and run with 'python'.
Install with 'pip3' and run with 'python3'.

Re: Using 7 segment display inside Python code

Posted: Thu May 30, 2019 6:27 pm
by Daveolw1
Thanks for that information, yes I think that is where I have gone wrong. It is Python3 and I used PIP, and Python.
Will have to start all over again. I missed where it said to change Python to Python3 and PIP to PIP3.

Thanks
David