PyInstaller+ Python3.5 (h5py import error)

Christian Gollwitzer auriocus at gmx.de
Wed Sep 23 20:07:44 CEST 2015


Am 23.09.15 um 18:20 schrieb Heli Nix:
> Dear all,
>
> Thanks a lot for your replies. Very helpful. I have already done some trials with Virtualenv, but PyInstaller is much closer to the idea of an installer you can pass to someone.
>
>   I have been using development version of PyInstaller in order to be able to use it with my script written with Python versin 3.3.5.
>
> I started with a very simple script just to test. I use the following command to create the distribution folder.
>
> pyinstaller test.py
>
> my script contains the following few lines and it runs ok on my own machine.
>
> import numpy as np
> import h5py
>
> a=np.arange(10)
> print(a)
> inputFiles="test.h5"
> with h5py.File(inputFiles, 'w') as inputFileOpen:
>    pass
>
> I am getting the following error related to importing h5py.
>
> [...]
> ImportError: No module named 'h5py.defs'

pyinstaller guesses from the code which modules are imported. It looks 
like if h5py imports a module h5py.defs, which is missing. For some 
programs, you need to support pyinstaller with additional information, 
especially if modules are loaded at runtime. Try:


pyinstaller --hidden-import=h5py.defs test.py

> If I modify my script to
>
> import numpy as np
> import h5py
> a=np.arange(10)
> print(a)

This is another hint: obviously h5py defers module loading until you 
first really open a HDF5 file. There pyinstaller has no means to find 
this out.

	Christian



More information about the Python-list mailing list