Answer the question
In order to leave comments, you need to log in
PyInstaller PyQt5 how to add ui file?
HELP! Hello ! I collect file.py into EXE pyinstaller file.py --onefile --noconsole --add
-data file.ui
Everything is assembled
In the dist folder I run EXE
writes fatal error!
but when I add file.ui to dist it works as it should
, but this is not just one EXE)
the question is how to push file.ui into EXE
Answer the question
In order to leave comments, you need to log in
Phew, just now I realized, the ui file must first be converted into a python with the command:
pyuic5.exe xxx.ui -o xxx_window.py -x -d
then import it, and only then slip it into pyinstaller.
In general, the documentation for PyInstaller has about the --add -data option and about how the compiled binary will work with attached data data at runtime. As for Windows - I don’t have tea in my soul, well, in one project under ubuntu I have such a function for extracting files from the data folder :
def bundle_data_path(path):
if getattr(sys, 'frozen', False):
bundle_dir = sys._MEIPASS
else:
bundle_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'data'
)
return os.path.join(bundle_dir, path)
...
# work with data.json
with open(bundle_data_path('data.json')) as data_file:
data = json.load(data_file)
list1 = data['list1']
list2 = data['list2']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question