Created
September 30, 2022 14:43
-
-
Save KPB3rd/fbe23585fa898456fac7ee0ec6e633f2 to your computer and use it in GitHub Desktop.
Get the directory location where the python script file is
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # get the location of the script, NOT the location we are running from | |
| # Consider if the code is run by python or exe | |
| # determine if application is a script file or frozen exe | |
| if getattr(sys, 'frozen', False): | |
| dir_path = os.path.dirname(sys.executable) | |
| elif __file__: | |
| dir_path = os.path.dirname(os.path.realpath(__file__)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment