Since this is the first question that comes up when searching for
OSError: Error reading file failed to load external entity
; I want to share a more general quick tip that helped me identify the problem and makes the error message more informative in the future:
import os
if not os.path.isfile(filename):
raise FileNotFoundError(filename)
By adding this check before parsing the file, you can immediately verify whether the file path is correct and get a much clearer error message if the file does not exist.