Search code examples
pythonpy2exe

How to compile multiple scripts with py2exe?


I have been recently working on a text game (executes in the console or CMD). I already tested it and it works perfectly. But now I want to make it a SINGLE EXE. I have already done that with other scripts. The proble is that this game is actually made of 3 scripts:main.py ,maps.py, UInterface.py. This are all imported in the main file like this

   import maps;
   import UInterface as UI;

What can I do to have everything into a single exe and make it work? Repeat, my code already worked, just need compiling


Solution

    1. Download and install - py2exe (link here http://www.py2exe.org/)

    2. Create a setup.py like this (in the source dir):

      from distutils.core import setup
      import py2exe
      
      setup(console = ['main.py'])
      
    3. And then run as:

      python setup.py py2exe
      
    4. exe will get creted here .\dist\main.exe