Skip to content

Error decoding JSON from C:\Users\admin\AppData\Roaming\Ultralytics\persistent_cache.json starting with an empty dictionary #19377

Answered by glenn-jocher
Huang-Ifei asked this question in Q&A
Discussion options

You must be logged in to vote

@Huang-Ifei for PyInstaller deployments with Ultralytics YOLO, we recommend implementing a first-run initialization check in your code to handle missing cache files. Add this before your main logic:

from pathlib import Path
cache_path = Path.home() / 'AppData/Roaming/Ultralytics/persistent_cache.json'
if not cache_path.exists():
    cache_path.parent.mkdir(parents=True, exist_ok=True)
    cache_path.write_text('{}')  # Initialize empty JSON

This creates the necessary file structure while maintaining proper Ultralytics functionality. For deployment best practices, see the PyInstaller integration guide in our documentation.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Huang-Ifei
Comment options

@glenn-jocher
Comment options

Answer selected by Huang-Ifei
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested dependencies Dependencies and packages
3 participants