pytables can't locate hdf5.dll when frozen using cx_freeze

513 views
Skip to first unread message

Nick Williams

unread,
Jul 15, 2015, 3:49:41 PM7/15/15
to pytable...@googlegroups.com
This issue sounds a lot like this one, but the fixes made to pytables there don't work in this case.

I am using cx_freeze to package up my app. cx_freeze creates an EXE and a ZIP with the required site-packages, including tables, in the distribution folder. It also copies all required DLL's, including hdf5.dll and python27.dll into the same folder as the EXE and ZIP. My app is called IPQC.exe:

dist/IPQC.exe
dist/IPQC.zip
dist/IPQC.zip/tables
...
dist/hdf5.dll
...

When I freeze the application it runs fine on a PC with the same Python distribution installed (specifically, Anaconda), but fails to run on a different PC without Python.

Despite the comment on PyTables/__init__.py#L41, my frozen app does seem to have a __file__ attribute, which points inside the ZIP file. So tables seems to only search these two explicit locations for hdf5.dll:
dllpaths in PyTables/__init__.py#L38: ('C:\\...\\Python\\pydcipqc\\IPQC\\dist\\IPQC.zip\\tables', '\\Library\\bin'). The first doesn't contain the DLL. The second doesn't exist.

I tried the following:
  • Manually adding hdf5.dll to dist/IPQC.zip/tables, but that didn't work.
  • Manually adding hdf5.dll to dist/Library/bin/ (which didn't previously exist), but that didn't work.
  • Explicitly adding the sys.executable path to my code prior to importing tables, but that did not work (although it definitely ensured the system path pulled in PyTables/__init__.py#L47 contained the right folder)
However, if I explicitly add the sys.executable path to PyTables/__init__.py#L38:
dllpaths = (os.path.abspath(
                os
.path.dirname(__file__)), ) + (os.path.dirname(sys.executable), ) + dllpaths

Everything works fine on all PCs, frozen, or not.

I am using Windows 8.1 64-bit with a 64-bit Python 2.7. Curiously I tried the same cx_freeze routine on a different Windows 8.1 PC with 64 bit Enthought Canopy python 2.7, and everything works fine without needing the change listed above. I know for a fact there are some package version differences between the two distributions, but both have pytables 3.2.0.  

Thanks for any help,
Nick

Nick Williams

unread,
Jul 15, 2015, 3:55:39 PM7/15/15
to pytable...@googlegroups.com
Sorry, forgot to include the traceback I get when running the frozen code, without the fix:
Traceback (most recent call last):
  File "C:\Users\Nick\Anaconda\lib\site-packages\cx_Freeze\initscripts\Console.p
y", line 27, in <module>
  File "IPQCController.py", line 1, in <module>
  File "C:\Box Sync\Nick Williams\Programming\Python\pydcipqc\IPQC\model\__init_
_.py", line 3, in <module>
  File "C:\Box Sync\Nick Williams\Programming\Python\pydcipqc\IPQC\model\data.py
", line 1, in <module>
  File "C:\Users\Nick\Anaconda\lib\site-packages\tables\__init__.py", line 78, i
n <module>
ImportError: Could not load "hdf5.dll", please ensure that it can be found in th
e system path

John David Reaver

unread,
Sep 16, 2015, 8:34:21 PM9/16/15
to pytables-users
Hey Nick, did you ever find a solution to this? I am coming across the exact same issue.

Nick Williams

unread,
Oct 5, 2015, 12:18:33 PM10/5/15
to John David Reaver, pytables-users

Nope, you're the first response. I just edit the pytables code as listed in my post. It works every time, but I have to remember to make the change.

Nick


--
You received this message because you are subscribed to a topic in the Google Groups "pytables-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pytables-users/m6hua7Wc0Gw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pytables-user...@googlegroups.com.
To post to this group, send email to pytable...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gaëtan de Menten

unread,
Oct 8, 2015, 4:18:51 PM10/8/15
to Nick Williams, John David Reaver, pytable...@googlegroups.com

This is an anaconda-specific bug (not present upstream)...
See
https://github.com/ContinuumIO/anaconda-issues/issues/444

You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-user...@googlegroups.com.

Nick Williams

unread,
Oct 8, 2015, 4:38:27 PM10/8/15
to Gaëtan de Menten, John David Reaver, pytable...@googlegroups.com

Great. Thanks for confirming. As noted, the fix is easy, but good to know it might be resolved soon.

Nick

Reply all
Reply to author
Forward
0 new messages