简体   繁体   中英

How do i convert python project having many python files and input video for the main.py as a single executable file?

I have the following folders in my project
    1. fire.py
    2.main.py
    3.traffic.avi   #video file
    4. vechile.py
  1. I have already used py2exe GUI but in that you can't create a exe file for my scenario.Because i have a video and a few import files. My program main.py imports fire.py and vechile.py and the main program requires this video traffic.avi . Now how do I convert this entire thing into one executable file. I want the entire project to run when the .exe is created. Single file can be converted into exe file using pyinstaller but how do i convert this type of project containing video file and the main.py importing two python files fire.py and vechile.py and taking input video traffic.avi for processing.If possible provide the solution with steps for this scenario.

pyinstaller --add-data 'traffic.avi:traffic.avi' --onefile main.py should work.

For accessing the file, have a look at Bundling data files with PyInstaller (--onefile)

EDIT: You don't have to add the other files manually, if you imported the classes or methods into your main.py as far as i know. Pyinstaller resolves those dependencies by itself. I corrected my command above. Looks like you have to specify the target-filename as well.

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