简体   繁体   中英

Python script with file dependencies and output files to executable

So I have a GUI script file that works well when running from command line. However when I use pyinstaller and auto-py-to-exe, I keep getting

MEIPASSxxx file exists but should not

errors

My folder is

-ML Model Output
-sun valley ttk theme
-icon.ico
-GUI_output_1.csv
-GUI_output_2.csv
-GUI_script.py

Essentially the script.py is a Tkinter GUI. It takes user input and runs it through the ML Model. Based on the ML classification the user input goes into one of the CSV files. The idea is that the user should be able to access the csv to use the data for next steps.

I've tried different versions of pyinstaller and auto-py-to-exe. —one file, —one dir, adding the additional files and folders. All of them basically gives this error.

I understand the meipass is a temp folder where pyinstaller unpacks data. But I've gone to the temp folder and deleted the folders. I am not sure how to fix this, all examples I've found are using very simple examples. Any advice for how to go about this? I need to get a single executable to share with client.

So I was able to fix this using the following code:

pyinstaller --noconfirm --onedir --windowed 
--icon "C:[path]/icon.ico" 
--add-data "C:[path]/GUI_output_1.csv;." 
--add-data "C:[path]/GUI_output_2.csv;." 
--add-data "C:[path]/icon.ico;." 
--add-data "C:[path]/Model;Model/" 
--add-data "C:[path]/Sun-Valley-ttk-theme-master;Sun-Valley-ttk-theme-master/" 
--paths "C:[path]/anaconda3/Lib/site-packages" 
--hidden-import "pytorch" --hidden-import "tkinter
--collect-data "torch" 
--copy-metadata "torch" --copy-metadata "tqdm" --copy-metadata "regex" --copy-metadata "sacremoses" --copy-metadata "requests" --copy-metadata "packaging" --copy-metadata "filelock" --copy-metadata "numpy" --copy-metadata "tokenizers" --copy-metadata "importlib_metadata" " 
"C:[path]/GUI_script.py"

The above was all one line, but broke the code up into different lines so that it would be easy to read for other users

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM