PyInstaller + UI Files – FileNotFoundError: [Errno 2] No such file or directory:

After scratching my head all weekend and looking further on SO, I managed to compile the standalone .exe as expected using the UI files. Firstly, I defined the following function using this answer Bundling data files with PyInstaller (–onefile) # Define function to import external files when using PyInstaller. def resource_path(relative_path): “”” Get absolute path … Read more

How do I include files with pyinstaller?

Sorry, I thought that only -F/–one-file makes such behavior, but looks like any bundling with pyinstaller needs such changes. You need to change your code like this, as explained in this answer: import sys if getattr(sys, ‘frozen’, False): image = PhotoImage(file=os.path.join(sys._MEIPASS, “files/bg.png”)) else: image = PhotoImage(file=”files/bg.png”) And then bundle it with pyinstaller like this: pyinstaller … Read more

Kivy: compiling to a single executable

Based on the links provided by KeyWeeUsr (Bundling data files with PyInstaller and Using PyInstaller to make EXEs from Python scripts) and combining that with Kivy’s resource path method, here’s a workable solution. I feel it’s a bit rough around the edges because it uses SYS._MEIPASS (I would prefer a public API) and requires adding … Read more

PyInstaller and Pandas

I ran into the same issue. I boiled it down to a simple script like this Hello.py: import pandas print “hello world, pandas was imported successfully!” To get pandas to import at run-time correctly I had to modify the Hello.spec to the following: # -*- mode: python -*- block_cipher = None def get_pandas_path(): import pandas … Read more