Skip to content

Fix NameError: piomatter is not defined in pi5_adapter#122

Merged
ty-porter merged 2 commits intoty-porter:mainfrom
falkyre:fix/pi5-imports
Mar 4, 2026
Merged

Fix NameError: piomatter is not defined in pi5_adapter#122
ty-porter merged 2 commits intoty-porter:mainfrom
falkyre:fix/pi5-imports

Conversation

@falkyre
Copy link
Copy Markdown
Contributor

@falkyre falkyre commented Mar 3, 2026

The Issue:
When running the emulator on a Raspberry Pi 5 using the pi5_adapter, a NameError: name 'piomatter' is not defined occurs in load_emulator_window.

This happened because adafruit_blinka_raspberry_pi5_piomatter was being conditionally imported inside the __ensure_pi5_runtime method. Because the import was scoped to that specific method, the piomatter module was not available globally to other methods in the class (such as load_emulator_window), causing it to crash when creating the canvas.

The Fix:

  • Moved the conditional import of adafruit_blinka_raspberry_pi5_piomatter to the module level (top of init.py) using a try...except ImportError block.
  • If the import fails (e.g., the [pi5] extras were not installed), it safely falls back to piomatter = None.
  • Updated __ensure_pi5_runtime to check if piomatter is None: to trigger the standard Logger.critical() dependency warning and sys.exit(1).

This ensures that the hardware and dependency validations continue to function exactly as intended, while properly scoping the piomatter module so that load_emulator_window can access it successfully.

@ty-porter ty-porter merged commit dd81a46 into ty-porter:main Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants