Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

building executable using python,vtk and py2exe

Tags:

python

py2exe

vtk

Is it possible to create a binary executable with py2exe for vtk?

Could someone provide a minimum working example or at least some hints? Py2exe is not necessary. If there is a working solution on other similar programs (bbfreeze etc) I am intrested too.

like image 274
pmav99 Avatar asked Aug 13 '11 13:08

pmav99


People also ask

What is the use of py2exe?

py2exe is a Python extension which converts Python scripts (. py) into Microsoft Windows executables (.exe). These executables can run on a system without Python installed. It is the most common tool for doing so.

Is py2exe safe?

Is py2exe safe to use? The python package py2exe was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as safe to use.


1 Answers

This example uses py2exe. Use packages to add any referenced libraries and options includes to add dependencies. I am not too sure about the exact semantics and I reached this stable configuration after much trial and error. Hopefully, you can use this as a template to go ahead.

from distutils.core import setup
import py2exe
import modulefinder
from iso8601 import iso8601

setup(name='exeExample',
      version='1.0',
      description='Exe example using py2Exe',
      author='Urjit Singh Bhatia',
      author_email='[email protected]',
      packages=['example', 'someLib'],
      console=['src\\a.py',
               'src\\b.py',
               'src\\c.py',
               'src\\d.py'],
      options={"py2exe":{"includes":["someLib","csv","iso8601","pymssql","uuid","decimal","urllib2","traceback","re","_mssql","os"]}}
     )

Keep in mind that options, includes sometimes need to be nested. That means, if pymssql here uses _mssql, it was giving me an error saying that _mssql was missing, so I had to explicitly go and add that as a dependency.

I hope someone can improve and explain.

Edits: 1. Added imports. 2. Simply running this creates a folder called dist where you will see the exe(s) and the dependencies.

like image 98
Urjit Avatar answered Oct 04 '22 06:10

Urjit