2
I have python project as below

sample
    src
        config
            sam.xml
        xmltest.py

Here I need to make exe file bundled with sam.xml file. Since xmltest.py depends on sam.xml file for config info i need to bundle the exe with xml as single exe file using pyinstaller.

we can make the exe file with below command. So it can bundled as single exe file.

pyinstaller xmltest.py --onefile

But sam.xml is not bundled with exe file.

I need the xml file bundled with exe file not outside the exe or any folder.

Is there anyway to bundle the xml file with exe using pyinstaller or any other way?

Sathish
  • 196
  • 7
  • 1
    Possible duplicate of [Add config file outside Pyinstaller --onefile exe into dist directory](https://stackoverflow.com/questions/47850064/add-config-file-outside-pyinstaller-onefile-exe-into-dist-directory) – Bernhard Nov 19 '18 at 08:26
  • I need the xml file bundled with exe file not outside the exe or any folder. @ Bernhard – Sathish Nov 19 '18 at 08:31
  • Because the sam.xml will not be customized by the user – Sathish Nov 19 '18 at 08:37
  • Sorry, can't you use the add-data parameter in that case? – Bernhard Nov 19 '18 at 08:38
  • Is this one datas=[] in .spec file? – Sathish Nov 19 '18 at 08:42
  • pyinstaller does have a command line parameter to add data into the --onefile, called --add-data `pyinstaller xmltest.py --onefile --add-data sam.xml` https://pyinstaller.readthedocs.io/en/v3.3.1/usage.html – Bernhard Nov 19 '18 at 08:45
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/183876/discussion-between-sathish-and-bernhard). – Sathish Nov 19 '18 at 09:36
  • pyinstaller xmltest.py --onefile --add-data sam.xml Does this worked for you? pyinstaller ....py -w --onefile --add-data ....xml I had tried this but Mine was giving pyinstaller: error: argument --add-data: invalid add_data_or_binary value: '........xml' this error any help for me @Bernhard – imxitiz Jul 27 '20 at 04:14

0 Answers0