Building a windows python exe that uses h5py

609 views
Skip to first unread message

Mike G

unread,
Apr 24, 2013, 3:04:36 AM4/24/13
to h5...@googlegroups.com
Has anyone successfully built and run python exe that uses h5py ?

I have tried with py2exe and pyinstaller but with no success. Get an exe but crashes at run time.

If you have done this  could you please share some details here . Thank you !!!!!!

Joel B. Mohler

unread,
Apr 24, 2013, 2:30:41 PM4/24/13
to h5...@googlegroups.com

Yes, I've created such an exe with py2exe (and more recently with cx_freeze).  This exe has been used successfully on multiple machines and it uses h5py heavily (through https://pypi.python.org/pypi/h5pom).   An example with the basic script & setup.py follows.  You should likely reply with more details about what "crashes at run time" means if this is not helpful.  If it gives you a traceback about missing modules then its likely that this reply will help you.  If it segfaults (hmm, I mean the windows version of that!), then there's something more interesting going on.  Figuring out the includes and excludes for py2exe I find to be a rather black art of trial & error.

---  h5py\example.py ----
import h5py

f=h5py.File("package_test.h5")
f.close()
---------------------------------


---  setup.py  ---
from distutils.core import setup
import py2exe

# h5py example
# NOTE:  h5py needs numpy so this builds on the numpy example
options = {}
options["py2exe"] = {"includes": ["h5py.defs", "h5py.utils", "h5py._proxy"],
                    "excludes": ["h5py.ipy_completer", "IPython", "Tkinter", "tcl"]}

setup(console=[r'scripts\h5py_example.py'], options=options)
---------------------------------

Mike G

unread,
May 20, 2013, 10:27:36 AM5/20/13
to h5...@googlegroups.com
Joel , thank you, your script is perfect!
Reply all
Reply to author
Forward
0 new messages