0

Matrix Portal - No module named "adafruit_portalbase
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Matrix Portal - No module named "adafruit_portalbase

by SloJoe on Wed Mar 31, 2021 11:16 pm

Hello everyone,
Let me apologize up front as this is my first attempt at programming a board. I am trying to build the Matrix Portal Scoreboard. I have followed the directions very carefully but have run into the following error:

code.py output:
Traceback (most recent call last):
File "code.py", line 8, in <module>
File "adafruit_matrixportal/matrixportal.py", line 32, in <module>
ImportError: no module named 'adafruit_portalbase'

I have searched through the code and don't see where it asks for that module.
I am using libraries from the bundle 6.x-mpy-20210330.

Any assistance would be greatly appreciated. And please let me know if I need to provide more information. Below, I will attach the code I have up to the last line given in the error.

Code: Select all | TOGGLE FULL SIZE
# Scoreboard matrix display
# uses AdafruitIO to set scores and team names for a scoreboard
# Perfect for cornhole, ping pong, and other games

import time
import board
import terminalio
from adafruit_matrixportal.matrixportal import MatrixPortal

# --- Display setup ---
matrixportal = MatrixPortal(status_neopixel=board.NEOPIXEL, debug=False)

RED_COLOR = 0xAA0000
BLUE_COLOR = 0x0000AA

# Red Score
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(4, int(matrixportal.graphics.display.height * 0.75) - 3),
    text_color=RED_COLOR,
    text_scale=2,
)

# Blue Score
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(36, int(matrixportal.graphics.display.height * 0.75) - 3),
    text_color=BLUE_COLOR,
    text_scale=2,
)

# Red Team name
matrixportal.add_text(
    text_font=terminalio.FONT,
    text_position=(4, int(matrixportal.graphics.display.height * 0.25) - 4),
    text_color=RED_COLOR,
)

SloJoe
 
Posts: 4
Joined: Mon Mar 29, 2021 3:00 pm

Re: Matrix Portal - No module named "adafruit_portalbase

by dastels on Thu Apr 01, 2021 10:19 am

The portalbase module contains the PortalBase class which is the base class of MatrixPortal. It contains all the common *Portal behavior and state.

In the expanded bundle: copy the directory lib/adafruit_portalbase to CIRCUITPY/lib.

Dave

dastels
 
Posts: 5884
Joined: Tue Oct 20, 2015 3:22 pm

Re: Matrix Portal - No module named "adafruit_portalbase

by SloJoe on Thu Apr 01, 2021 6:52 pm

Thank you for the assistance, Dastels.
I have added the library, adafruit_portalbase like you said. Now it has moved on to a new issue.

code.py output:
Traceback (most recent call last):
File "code.py", line 58, in <module>
File "adafruit_portalbase/__init__.py", line 305, in set_text_color
AttributeError: 'NoneType' object cannot assign attribute 'color'

One thing I noticed is all the files in the libraries are all .mpy and my softwares (Mu 1.1 and PyCharm) are unable to see these code extensions.
The error above would lead me to believe it is looking for _init_.py instead of the _init_.mpy which is what is in there.

dastels wrote:The portalbase module contains the PortalBase class which is the base class of MatrixPortal. It contains all the common *Portal behavior and state.

In the expanded bundle: copy the directory lib/adafruit_portalbase to CIRCUITPY/lib.

Dave

SloJoe
 
Posts: 4
Joined: Mon Mar 29, 2021 3:00 pm

Re: Matrix Portal - No module named "adafruit_portalbase

by dastels on Thu Apr 01, 2021 7:33 pm

Files ending in MPY are precompiled PY code. This avoids taking the time and memory to compile them (to bytecode) when they are loaded.

OK. I would try deleting everything in CIRCUITPY/lib (after taking note of what's there) and emptying trash. Then copy back what was there from the latest bundle.

Sometimes old code gets left over and confuses things.

Dave

dastels
 
Posts: 5884
Joined: Tue Oct 20, 2015 3:22 pm

Re: Matrix Portal - No module named "adafruit_portalbase

by SloJoe on Thu Apr 01, 2021 9:24 pm

I am sorry, that I am still a bothering you with this. I deleted my library and there was no trash to empty. I loaded all the required libraries per the instructions, plus "adafruit_portalbase" and "adafruit_fakerequest."

I still got the same error,
code.py output:
Traceback (most recent call last):
File "code.py", line 58, in <module>
File "adafruit_portalbase/__init__.py", line 305, in set_text_color
AttributeError: 'NoneType' object cannot assign attribute 'color'

When I look at the area in the code around line 58, I see that it is trying to establish the colors:
Code: Select all | TOGGLE FULL SIZE
SCORES_RED_FEED = "scores-group.red-team-score-feed"
SCORES_BLUE_FEED = "scores-group.blue-team-score-feed"
TEAM_RED_FEED = "scores-group.red-team-name"
TEAM_BLUE_FEED = "scores-group.blue-team-name"
UPDATE_DELAY = 4

matrixportal.set_text_color(RED_COLOR, 0)
matrixportal.set_text_color(BLUE_COLOR, 1)


def show_connecting(show):
    if show:
        matrixportal.set_text(".", 4)
    else:
        matrixportal.set_text(" ", 4)


So I guess there is in error in the "adafruit_portalbase/__init__.py" file that isn't allowing it to "assign the 'color'"?

dastels wrote:Files ending in MPY are precompiled PY code. This avoids taking the time and memory to compile them (to bytecode) when they are loaded.

OK. I would try deleting everything in CIRCUITPY/lib (after taking note of what's there) and emptying trash. Then copy back what was there from the latest bundle.

Sometimes old code gets left over and confuses things.

Dave

SloJoe
 
Posts: 4
Joined: Mon Mar 29, 2021 3:00 pm

Re: Matrix Portal - No module named "adafruit_portalbase

by dastels on Fri Apr 02, 2021 11:29 am

From the look of the library code, my thought it that you need to set text first.

Dave

dastels
 
Posts: 5884
Joined: Tue Oct 20, 2015 3:22 pm

Re: Matrix Portal - No module named "adafruit_portalbase

by SloJoe on Mon Apr 05, 2021 7:21 pm

Hey Dave, Hope you had a nice weekend.
Sorry for the delay. The holiday weekend tied me up. So I am wondering if the code that was used to create this scoreboard may be broken now due to library updates. I am wondering how I can set text if the issue lies in the .mpy file. Also my matrix only shows the purple circuit python symbol and what appears to be code cutoff at the top of the LED matrix (Picture attached). I am assuming that is because there are still errors in the code.

Thanks,
Joe

dastels wrote:From the look of the library code, my thought it that you need to set text first.

Dave
Attachments
Point Blur_Apr052021_181530.jpg
Point Blur_Apr052021_181530.jpg (624.47 KiB) Viewed 28 times

SloJoe
 
Posts: 4
Joined: Mon Mar 29, 2021 3:00 pm

Re: Matrix Portal - No module named "adafruit_portalbase

by dastels on Mon Apr 05, 2021 7:30 pm

Try with the new 6.2 when it's available (should be any time now... as the build system gets it build and uploaded). and a fresh copy of the modules. Again, empty CIRCUITPY/lib and copy over fresh ones from the latest buldle.

Let me know if that helps.

Dave

dastels
 
Posts: 5884
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.