Get absolute path to resource, works for dev and for PyInstaller
(relative_path)
| 25 | |
| 26 | # Location of packaged resource files when running pyinstaller --onefile |
| 27 | def resource_path(relative_path): |
| 28 | """ Get absolute path to resource, works for dev and for PyInstaller """ |
| 29 | try: |
| 30 | # PyInstaller creates a temp folder and stores path in _MEIPASS |
| 31 | base_path = sys._MEIPASS |
| 32 | except Exception: |
| 33 | base_path = os.path.dirname(__file__) |
| 34 | |
| 35 | return os.path.join(base_path, relative_path) |
| 36 | |
| 37 | |
| 38 | # If application is frozen executable |