ultralytics/ultralytics · error · ValueError
❌ JSON file path cannot be empty.
Error message
❌ JSON file path cannot be empty.
What it means
ParkingManagement.__init__ reads json_file from its config (CFG['json_file']) and immediately refuses to continue when it is empty/None: parking regions are the core data structure of this solution, and there is no sensible default. A warning names the missing argument and ValueError follows, so construction fails fast rather than crashing later at process() time.
Source
Thrown at ultralytics/solutions/parking_management.py:210
Methods:
process: Process the input image for parking lot management and visualization.
Examples:
>>> from ultralytics.solutions import ParkingManagement
>>> parking_manager = ParkingManagement(model="yolo26n.pt", json_file="parking_regions.json")
>>> print(f"Occupied spaces: {parking_manager.pr_info['Occupancy']}")
>>> print(f"Available spaces: {parking_manager.pr_info['Available']}")
"""
def __init__(self, **kwargs: Any) -> None:
"""Initialize the parking management system with a YOLO model and visualization settings."""
super().__init__(**kwargs)
self.json_file = self.CFG["json_file"] # Load parking regions JSON data
if not self.json_file:
LOGGER.warning("ParkingManagement requires `json_file` with parking region coordinates.")
raise ValueError("❌ JSON file path cannot be empty.")
with open(self.json_file, encoding="utf-8") as f:
self.json = json.load(f)
self.pr_info = {"Occupancy": 0, "Available": 0} # Dictionary for parking information
self.arc = (0, 0, 255) # Available region color
self.occ = (0, 255, 0) # Occupied region color
self.dc = (255, 0, 189) # Centroid color for each box
def process(self, im0: np.ndarray) -> SolutionResults:
"""Process the input image for parking lot management and visualization.
This function analyzes the input image, extracts tracks, and determines the occupancy status of parking regions
defined in the JSON file. It annotates the image with occupied and available parking spots, and updates the
parking information.
Args:View on GitHub (pinned to 0449ea011c)
Solutions
- Create a parking-regions JSON (list of regions with polygon coordinates) and pass ParkingManagement(json_file='parking_regions.json')
- Verify the kwarg name is exactly json_file so it lands in CFG
- Use the official parking management example JSON structure as the template
Example fix
# before manager = ParkingManagement(model='yolo26n.pt') # ValueError # after manager = ParkingManagement(model='yolo26n.pt', json_file='parking_regions.json')
Defensive patterns
Strategy: validation
Validate before calling
assert json_file and Path(json_file).is_file(), 'supply an existing parking regions JSON'
Prevention
- Prepare and validate the parking-regions JSON before constructing ParkingManagement
- Reuse the documented example JSON structure for region coordinates
When it happens
Trigger: Instantiating ParkingManagement() without json_file, or with json_file='' / None — e.g. copying the constructor from another solution (ObjectCounter) that needs no JSON and forgetting this one does.
Common situations: Adapting example scripts; passing the JSON path under a wrong kwarg name (e.g. json='...') so the real json_file stays empty; config dicts loaded from files missing the json_file key.
Related errors
- Unsupported analytics_type='{self.type}'. Supported types: l
- {key} is not a valid solution argument, see {url}
- '{k}={v}' is of invalid type {type(v).__name__}. Valid '{k}'
- '{k}={v}' is of invalid type {type(v).__name__}. '{k}' must
- '{k}={v}' is an invalid value. '{k}' must be >= {CFG_INT_MIN
AI-assisted analysis of ultralytics/ultralytics@0449ea011c (2026-08-15).
Data as JSON: /api/errors/9ab7b5265567de1a.
Report an issue: GitHub.