How to use pyinstaller for keras?

Viewed 519

I have written just one line in a python code to import keras and then I want to build an executable of this using pyinstaller. I ran below command to generate executable

pyinstaller --onefile test.py

and I am getting below error while running generated executable.

    Using TensorFlow backend.
  Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import keras
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "keras/__init__.py", line 3, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "keras/utils/__init__.py", line 6, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "keras/utils/conv_utils.py", line 3, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "keras/backend/__init__.py", line 83, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "keras/backend/tensorflow_backend.py", line 1, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "tensorflow/__init__.py", line 28, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "tensorflow/python/__init__.py", line 73, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "tensorflow/python/ops/standard_ops.py", line 25, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "tensorflow/python/autograph/__init__.py", line 37, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "tensorflow/python/autograph/core/converter.py", line 71, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "tensorflow/python/autograph/pyct/cfg.py", line 41, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "tensorflow/python/autograph/pyct/compiler.py", line 32, in <module>
  File "/tmp/pip-install-n_54L1/pyinstaller/PyInstaller/loader/pyimod03_importers.py", line 391, in load_module
  File "astor/__init__.py", line 24, in <module>
IOError: [Errno 2] No such file or directory: '/tmp/_MEIJXmwkj/astor/VERSION'
[32046] Failed to execute script test

This is my specs files:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


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

Any help/hint will be appreciated on this issue, or how can you create a single file executable for keras/tensorflow models.

0 Answers
Related