import os script_dir = os.path.dirname(__file__) file_path = os.path.join(script_dir, 'relative/path/to/file.json') with open(file_path, 'r') as fi: pass