Adding a data file in Pyinstaller using the onefile option

后端 未结 4 1049
感情败类
感情败类 2020-12-05 20:37

I\'m trying to add an image to the one file produced by Pyinstaller. I\'ve read many questions/forums like this one and that one and still it\'s not working.

I know

4条回答
  •  悲哀的现实
    2020-12-05 20:59

    I tried changed my python script's working directory, and it seems to work:

    import os 
    import sys
    
    os.chdir(sys._MEIPASS)
    os.system('included\\text.txt')
    

    my pyinstaller command:

    pyinstaller --onefile --nowindow --add-data text.txt;included winprint.py --distpath .
    

提交回复
热议问题