Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何为keras使用pyinstaller?_Python_Tensorflow_Keras_Pyinstaller - Fatal编程技术网

Python 如何为keras使用pyinstaller?

Python 如何为keras使用pyinstaller?,python,tensorflow,keras,pyinstaller,Python,Tensorflow,Keras,Pyinstaller,我在python代码中只编写了一行代码来导入keras,然后我想使用pyinstaller构建此代码的可执行文件。 我运行下面的命令来生成可执行文件 pyinstaller--onefile test.py 在运行生成的可执行文件时,我得到了以下错误 Using TensorFlow backend. Traceback (most recent call last): File "test.py", line 1, in <module>

我在python代码中只编写了一行代码来导入keras,然后我想使用pyinstaller构建此代码的可执行文件。 我运行下面的命令来生成可执行文件

pyinstaller--onefile test.py

在运行生成的可执行文件时,我得到了以下错误

    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
对于这个问题,或者您如何为keras/tensorflow模型创建单个文件可执行文件,我们将不胜感激

# -*- 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 )