PyInstaller+ Python3.5 (h5py import error)

Heli Nix hemla21 at gmail.com
Wed Sep 23 18:20:43 CEST 2015


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. 

test returned -1
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/usr/lib/python3.3/site-packages/PyInstaller-3.0.dev2-py3.3.egg/PyInstaller/loader/pyimod03_importers.py", line 311, in load_module
  File "/usr/lib64/python3.3/site-packages/h5py/__init__.py", line 23, in <module>
  File "/usr/lib/python3.3/site-packages/PyInstaller-3.0.dev2-py3.3.egg/PyInstaller/loader/pyimod03_importers.py", line 493, in load_module
  File "h5r.pxd", line 21, in init h5py._conv (/tmp/pip_build_root/h5py/h5py/_conv.c:6563)
  File "/usr/lib/python3.3/site-packages/PyInstaller-3.0.dev2-py3.3.egg/PyInstaller/loader/pyimod03_importers.py", line 493, in load_module
  File "_objects.pxd", line 12, in init h5py.h5r (/tmp/pip_build_root/h5py/h5py/h5r.c:2708)
  File "/usr/lib/python3.3/site-packages/PyInstaller-3.0.dev2-py3.3.egg/PyInstaller/loader/pyimod03_importers.py", line 493, in load_module
  File "_objects.pyx", line 1, in init h5py._objects (/tmp/pip_build_root/h5py/h5py/_objects.c:6407)
ImportError: No module named 'h5py.defs'

If I modify my script to 

import numpy as np
import h5py
a=np.arange(10)
print(a)

 then, the created exectuable will run successfully on other linux machines.  Does anybody have any idea why I am getting the following h5py import error?

My spec file also looks like this:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['test.py'],
             pathex=['/home/albert/test'],
             binaries=None,
             datas=None,
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None,
             excludes=None,
             win_no_prefer_redirects=None,
             win_private_assemblies=None,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='test',
          debug=False,
          strip=None,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name='test')


Thank you very much in Advance for your help, 




More information about the Python-list mailing list