Daveolw1
Posts: 23
Joined: Thu May 16, 2019 10:24 am

Using 7 segment display inside Python code

Wed May 29, 2019 8:39 pm

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

User avatar
MrYsLab
Posts: 371
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: Using 7 segment display inside Python code

Wed May 29, 2019 9:04 pm

It appears you did not install the library properly. You can find detailed install instructions here: https://luma-led-matrix.readthedocs.io/en/latest/

Andyroo
Posts: 4227
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Using 7 segment display inside Python code

Wed May 29, 2019 9:41 pm

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?
Need Pi spray - these things are breeding in my house...

Daveolw1
Posts: 23
Joined: Thu May 16, 2019 10:24 am

Re: Using 7 segment display inside Python code

Thu May 30, 2019 6:36 am

Yes I followed those instructions and did the checks to confirm it had everything installed.
Yes it is Python as stated in my post.

ghp
Posts: 1402
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Using 7 segment display inside Python code

Thu May 30, 2019 6:51 am

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.

Daveolw1
Posts: 23
Joined: Thu May 16, 2019 10:24 am

Re: Using 7 segment display inside Python code

Thu May 30, 2019 2:21 pm

No name is "test7seg.py"

User avatar
DougieLawson
Posts: 35815
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Using 7 segment display inside Python code

Thu May 30, 2019 3:38 pm

Did you install with pip (python2) or pip3 (python3)?
Are you running with python (aka python2) or python3?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

ghp
Posts: 1402
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Using 7 segment display inside Python code

Thu May 30, 2019 3:39 pm

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'.

Daveolw1
Posts: 23
Joined: Thu May 16, 2019 10:24 am

Re: Using 7 segment display inside Python code

Thu May 30, 2019 6:27 pm

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

Return to “Python”