Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a standalone windows exe which does not require pythonXX.dll

is there a way to create a standalone .exe from a python script. Executables generated with py2exe can run only with pythonXX.dll. I'd like to obtain a fully standalone .exe which does not require to install the python runtime library. It looks like a linking problem but using static library instead the dynamic one and it would be also useful to apply a strip in order to remove the unused symbols.

Any idea ?

Thanks.

Alessandro

like image 576
alexroat Avatar asked Apr 01 '09 20:04

alexroat


People also ask

Can you make a python executable?

Underneath the GUI is PyInstaller, a terminal based application to create Python executables for Windows, Mac and Linux. Veteran Pythonistas will be familiar with how PyInstaller works, but with auto-py-to-exe any user can easily create a single Python executable for their system.

Which is better py2exe or PyInstaller?

In PyInstaller it is easy to create one exe, By default both create a bunch of exes & dlls. In py2exe its easier to embed manifest file in exe, useful for run as administrator mode in windows vista and beyond. Pyinstaller is modular and has a feature of hooks to include files in the build that you like.


1 Answers

You can do this in the latest version of py2exe...
Just add something like the code below in your setup.py file (key part is 'bundle_files': 1).

To include your TkInter package in the install, use the 'includes' key.

distutils.core.setup(
      windows=[
            {'script': 'yourmodule.py',
             'icon_resources': [(1, 'moduleicon.ico')]
            }
      ],
      zipfile=None,
      options={'py2exe':{
                         'includes': ['tkinter'],
                         'bundle_files': 1
                        }
      }
  )
like image 172
Jason Coon Avatar answered Sep 17 '22 12:09

Jason Coon