frozen_dir.py 576 B

123456789101112131415161718
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. """
  4. @Contact : liuyuqi.gov@msn.cn
  5. @Time : 2024/04/12
  6. @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
  7. @Desc :
  8. """
  9. import sys
  10. import os
  11. def get_app_path() -> str:
  12. """Returns the base application path."""
  13. if hasattr(sys, 'frozen'):
  14. # Handles PyInstaller
  15. return os.path.dirname(sys.executable) #使用 pyinstaller 打包后的 exe 目录
  16. # return os.path.dirname(os.path.dirname(os.path.dirname(__file__))) # 没打包前的py目录
  17. return sys.path[0]