[PR #24] Fix matplotlib import error with lazy import and fallback colors #79

Open
opened 2026-05-07 00:18:33 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/IAmTomShaw/f1-race-replay/pull/24
Author: @Jal-Bafana
Created: 12/2/2025
Status: 🔄 Open

Base: mainHead: main


📝 Commits (2)

  • eca3d31 Fix matplotlib import error with lazy import and fallback colors
  • d57bdc3 Fix matplotlib import error with lazy import and fallback colors

📊 Changes

2 files changed (+94 additions, -49 deletions)

View changed files

📝 main.py (+6 -17)
📝 src/f1_data.py (+88 -32)

📄 Description

Problem

The application fails to start on Python 3.13 due to a matplotlib import error when importing fastf1.plotting at module level.

Solution

  • Made fastf1.plotting import lazy (only when needed)
  • Added fallback color scheme when plotting module cannot be imported
  • Application now works even if matplotlib has compatibility issues

Changes

  • Removed top-level import fastf1.plotting
  • Wrapped import in try/except with fallback in get_driver_colors()
  • Added team-based color mapping as fallback

Testing

Tested on Python 3.13 where original code failed. Application now starts successfully.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/IAmTomShaw/f1-race-replay/pull/24 **Author:** [@Jal-Bafana](https://github.com/Jal-Bafana) **Created:** 12/2/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`eca3d31`](https://github.com/IAmTomShaw/f1-race-replay/commit/eca3d3127e380068345796d0dca88ccef52d87ac) Fix matplotlib import error with lazy import and fallback colors - [`d57bdc3`](https://github.com/IAmTomShaw/f1-race-replay/commit/d57bdc306d3964908a3716ee33cc00f62445cdab) Fix matplotlib import error with lazy import and fallback colors ### 📊 Changes **2 files changed** (+94 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `main.py` (+6 -17) 📝 `src/f1_data.py` (+88 -32) </details> ### 📄 Description ## Problem The application fails to start on Python 3.13 due to a matplotlib import error when importing `fastf1.plotting` at module level. ## Solution - Made `fastf1.plotting` import lazy (only when needed) - Added fallback color scheme when plotting module cannot be imported - Application now works even if matplotlib has compatibility issues ## Changes - Removed top-level `import fastf1.plotting` - Wrapped import in try/except with fallback in `get_driver_colors()` - Added team-based color mapping as fallback ## Testing Tested on Python 3.13 where original code failed. Application now starts successfully. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/f1-race-replay#79
No description provided.