diff --git a/Utils.py b/Utils.py index a3a529d7..f930335b 100644 --- a/Utils.py +++ b/Utils.py @@ -139,8 +139,11 @@ def local_path(*path: str) -> str: local_path.cached_path = os.path.dirname(os.path.abspath(sys.argv[0])) else: import __main__ - if hasattr(__main__, "__file__") and os.path.isfile(__main__.__file__): + if globals().get("__file__") and os.path.isfile(__file__): # we are running in a normal Python environment + local_path.cached_path = os.path.dirname(os.path.abspath(__file__)) + elif hasattr(__main__, "__file__") and os.path.isfile(__main__.__file__): + # we are running in a normal Python environment, but AP was imported weirdly local_path.cached_path = os.path.dirname(os.path.abspath(__main__.__file__)) else: # pray