Using pyinstaller to make an executable file from python .py file utilizing Pandas to read a CSV file? Using pyinstaller to make an executable file from python .py file utilizing Pandas to read a CSV file? tkinter tkinter

Using pyinstaller to make an executable file from python .py file utilizing Pandas to read a CSV file?


Based on this answer pyinstaller in --onefile mode creates a temporary directory every time you run the executable and stores its path in sys._MEIPASS variable. When accessing the CSV file in your code, you need to refer to this path.

For example (modified code from answer I mentioned above):

import os, systry: # running using executable    path = sys._MEIPASSexcept: # running using .py sript    path = os.path.abspath('.')csv_path = os.path.join(path, 'table.csv') # valid path of the csv file

For more info see: How the One-File Program Works, Defining the Extraction Location, Run-time Information