diff options
author | shirt-dev <2660574+shirt-dev@users.noreply.github.com> | 2021-02-25 17:58:02 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-26 04:28:02 +0530 |
commit | c552ae8838a27c29f2e1795791c152ef136826cd (patch) | |
tree | 584df8eed6b5ea7f179785ba326fb1534463abc1 | |
parent | 31a5e037a7341dddf166ef4c508f1b3f08b9e414 (diff) | |
download | hypervideo-pre-c552ae8838a27c29f2e1795791c152ef136826cd.tar.lz hypervideo-pre-c552ae8838a27c29f2e1795791c152ef136826cd.tar.xz hypervideo-pre-c552ae8838a27c29f2e1795791c152ef136826cd.zip |
Fix `get_executable_path` (#117)
Authored-by: shirtjs <2660574+shirtjs@users.noreply.github.com>
-rw-r--r-- | yt_dlp/utils.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 0dbb85467..12bc637f8 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -5945,9 +5945,13 @@ def make_dir(path, to_screen=None): def get_executable_path(): - path = os.path.dirname(sys.argv[0]) - if os.path.basename(sys.argv[0]) == '__main__': # Running from source - path = os.path.join(path, '..') + from zipimport import zipimporter + if hasattr(sys, 'frozen'): # Running from PyInstaller + path = os.path.dirname(sys.executable) + elif isinstance(globals().get('__loader__'), zipimporter): # Running from ZIP + path = os.path.join(os.path.dirname(__file__), '../..') + else: + path = os.path.join(os.path.dirname(__file__), '..') return os.path.abspath(path) |