EDIT: The latest versions of PyInstaller (4.0+) now include support for tensorflow
out of the box.
Create a directory structure like this:
- main.py # Your code goes here - don't bother actually naming you file this
- hooks
- hook-tensorflow.py
Copy the following into hook-tensorflow.py
:
from PyInstaller.utils.hooks import collect_all
def hook(hook_api):
packages = [
'tensorflow',
'tensorflow_core',
'astor'
]
for package in packages:
datas, binaries, hiddenimports = collect_all(package)
hook_api.add_datas(datas)
hook_api.add_binaries(binaries)
hook_api.add_imports(*hiddenimports)
Then, when compiling, add the command line option --additional-hooks-dir=hooks
.
If you come across more not found errors, simply add the full import name into the packages
list.
PS - for me, main.py
was simply from tensorflow import *
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…