I'm trying to run a Python program that uses FastF1 on the online Python IDE.
I don't have the admin rights to install Python on my desktop, so the online application is the only way to go.
For the same reason, I can't check if it's a problem related to the web-environment or the code itself.
I have pip installed FastF1 into the online environment, no issues there.
Despite that, I get the same runtime error every time I click on run.
Here's the code:
import fastf1
from pathlib import Path
from fastf1 import plotting
from matplotlib import pyplot as plt
plotting.setup_mpl()
#fastf1.Cache.enable_cache('path/to/folder/for/cache') # optional but recommended
fastf1.Cache.enable_cache(Path.cwd()) # optional but recommended
race = fastf1.get_session(2020,'Turkish Grand Prix','R')
race.load()
lec = race.laps.pick_driver('LEC')
ham = race.laps.pick_driver('HAM')
fig, ax = plt.subplots()
ax.plot(lec['LapNumber'],lec['LapTime'],color='red')
ax.plot(ham['LapNumber'],ham['LapTime'],color='cyan')
ax.set_title("LEC vs HAM")
ax.set_xlabel("Lap Number")
ax.set_ylabel("Lap Time")
plt.show()
When I run the code, this is the output I receive:
core INFO Loading data for Turkish Grand Prix - Race [v3.8.2]
req INFO No cached data found for session_info. Loading data...
_api INFO Fetching session info data...
logger WARNING Failed to load session info data!
req INFO No cached data found for driver_info. Loading data...
_api INFO Fetching driver list...
core WARNING Failed to load extended driver information!
req INFO No cached data found for session_status_data. Loading data...
_api INFO Fetching session status data...
logger WARNING Failed to load session status data!
req INFO No cached data found for lap_count. Loading data...
_api INFO Fetching lap count data...
logger WARNING Failed to load total lap count!
req INFO No cached data found for track_status_data. Loading data...
_api INFO Fetching track status data...
logger WARNING Failed to load track status data!
req INFO No cached data found for _extended_timing_data. Loading data...
_api INFO Fetching timing data...
logger WARNING Failed to load timing data!
core WARNING Failed to add first lap time from Ergast for drivers: ['18', '11', '5', '33', '23', '44', '3', '7', '55', '20', '99', '26', '10', '16', '4', '8', '63', '77', '31', '6']
req INFO No cached data found for car_data. Loading data...
_api INFO Fetching car data...
logger WARNING Failed to load telemetry data!
req INFO No cached data found for weather_data. Loading data...
_api INFO Fetching weather data...
logger WARNING Failed to load weather data!
req INFO No cached data found for race_control_messages. Loading data...
_api INFO Fetching race control messages...
logger WARNING Failed to load race control messages!
core INFO Finished loading data for 20 drivers: ['44', '11', '5', '16', '55', '33', '23', '4', '18', '3', '31', '26', '10', '77', '7', '63', '20', '8', '6', '99']
Traceback (most recent call last):
File "PythonFile_005_FastF1_Trial_001.py", line 14, in
lec = race.laps.pick_driver('LEC')
^^^^^^^^^
File "/app/.pypackages/lib/python3.12/site-packages/fastf1/core.py", line 1272, in laps
return self._get_property_warn_not_loaded('_laps')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.pypackages/lib/python3.12/site-packages/fastf1/core.py", line 1231, in _get_property_warn_not_loaded
raise exceptions.DataNotLoadedError(
fastf1.exceptions.DataNotLoadedError: The data you are trying to access has not been loaded yet. See `Session.load`
It fails to load most of the data it' looking for.
Replacing
lec = race.laps.pick_driver('LEC')
with
lec = race.laps.pick_driver('16')
or
lec = race.laps.pick_driver(16)
doesn't stop the traceback either.
Could you tell me what I'm doing wrong?