Determining application path in a Python EXE generated by pyInstaller

I found a solution. You need to check if the application is running as a script or as a frozen exe: import os import sys config_name=”myapp.cfg” # determine if application is a script file or frozen exe if getattr(sys, ‘frozen’, False): application_path = os.path.dirname(sys.executable) elif __file__: application_path = os.path.dirname(__file__) config_path = os.path.join(application_path, config_name)

How can I make a Python script standalone executable to run without ANY dependency? [duplicate]

You can use PyInstaller to package Python programs as standalone executables. It works on Windows, Linux, and Mac. PyInstaller Quickstart Install PyInstaller from PyPI: pip install pyinstaller Go to your program’s directory and run: pyinstaller yourprogram.py This will generate the bundle in a subdirectory called dist. pyinstaller -F yourprogram.py Adding -F (or –onefile) parameter will … Read more