3

Is there a way to use PyInstaller to create a single executable that also includes things such as text files and .ui files? How would I go about doing this?

1
  • If you are talking about QT .ui files, PyInstaller is aware of QT and will just work. What have you tried? Commented Jan 8, 2017 at 5:02

1 Answer 1

3

You can add items to a pyinstaller built exe using the spec file:

For example, to add a single README file to the top level of a one-folder app, you could modify the spec file as follows:

a = Analysis(... datas=[ ('src/README.txt', '.') ], ... ) 

You have made the datas= argument a one-item list. The item is a tuple in which the first string says the existing file is src/README.txt. That file will be looked up (relative to the location of the spec file) and copied into the top level of the bundled app.

The strings may use either / or \ as the path separator character. You can specify input files using “glob” abbreviations. For example to include all the .mp3 files from a certain folder:

a = Analysis(... datas= [ ('/mygame/sfx/*.mp3', 'sfx' ) ], ... ) 
Sign up to request clarification or add additional context in comments.

1 Comment

I believe this would work for me but pyinstaller seems to have issues with Windows 10 and late versions of Python

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.