2

I have 3 python scripts and many images in folders and tmx files which I want to make it as a single .exe . I wasnt able to find how to convert multiple python scripts and folders to single exe. I was only able to find cxfreeze and similar things for a single python script. Please help.

Thanks in advance.

Seen Lord
  • 23
  • 3

2 Answers2

2

You can add external files to your pyinstaller exe by using add-data. An example I'm using for one of my pygame games:

pyinstaller --onedir --clean --name "MyGame" --icon="images/icon.ico" --add-data "images/*.png:images" --add-data "sounds/*.mp3:sounds" --add-data "sounds/*.wav:sounds" --add-data "fonts/*.ttf:fonts" main.py
Christian
  • 739
  • 1
  • 5
  • 15
1

Create a setup.py file in cxfreeze. You have to pass multiple pyhton files as list in cxfreeze executables. Refere this thread -

Python cx_Freeze for two or more python files (modules)

For separate files like images, you have to include those files explicitly. Below is an example which worked for me on one of the project -

from cx_Freeze import setup, Executable

build_exe_options = {'packages': ['os', 'tkinter', 'matplotlib.backends.backend_svg', 'subprocess'],
                     'namespace_packages': ['mpl_toolkits'],
                     'include_files':['input3.json', 'SF.xlsx', 'SF logo.ico', 'Operative Temperature.pkl',
                                      'Rect_icon.png', 'Soltissim logo.png', 'SF full logo.jpg', 'IES logo.jpg']}

base = None

if sys.platform == 'win32':
    base = 'Win32GUI'

setup ( name = 'Soltissim',
        version = '2',
        description = 'SF GUI',
        options = {'build_exe': build_exe_options},
        executables = [Executable('Soltissim.py', base=base, icon='SF logo.ico'),
                       Executable('SF_English.py', base=base, icon='SF logo.ico'),
                       Executable('SF_French.py', base=base, icon='SF logo.ico')])



Furhter, if you want to create a build from setup which can be then used in program like inno, use following command in terminal - python setup.py build

If you want to create a simple windows installer directly from setup, use - python setup.py bdist_msi

tan_an
  • 196
  • 1
  • 10