SO Link
<https://stackoverflow.com/questions/57345721/how-to-fix-attributeerror-on-using-pyinstaller-on-a-project-with-tensorflow-an>
I tried..
* using:
hidden-imports
* modifying *pathex* of the spec file to include the directory path of the
module, which is retrieved from:
import tensorflow as tf
print(tf.keras.__file__)
And I'm currently at my wit's end trying to figure this out.
The whole error is:
D:\Shared\CMSC\190-2\readr>readr.exe
Limited tf.compat.v2.summary API due to missing TensorBoard installation
Limited tf.summary API due to missing TensorBoard installation
Traceback (most recent call last):
File "main.py", line 4, in <module>
from modules.model import models
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File
"d:\shared\cmsc\190-2\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py",
line 627, in exec_module
exec(bytecode, module.__dict__)
File "modules\model.py", line 4, in <module>
models = load_models(n=num_models)
File "modules\ai.py", line 28, in load_models
model = tf.keras.models.load_model(os.path.join('.', 'models', ('m' +
str(i) + 'eF.h5')))
AttributeError: module 'tensorflow' has no attribute 'keras'
[11288] Failed to execute script main
Basic requirements of my project:
numpy==1.16.4
opencv-python==4.1.0.25
pandas==0.25.0
PyInstaller==3.5
tensorflow==2.0.0a0
The *actual* requirements of my project, when I use *pip freeze*:
numpy==1.16.4
opencv-python==4.1.0.25
pandas==0.25.0
PyInstaller==3.5
tensorflow==2.0.0a0
The extended requirements (downloaded and installed too when installing the
basic requirements):
absl-py==0.7.1
altgraph==0.16.1
astor==0.8.0
future==0.17.1
gast==0.2.2
google-pasta==0.1.7
grpcio==1.22.0
h5py==2.9.0
Keras==2.2.4
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
Markdown==3.1.1
numpy==1.17.0
opencv-python==4.1.0.25
pandas==0.25.0
pefile==2019.4.18
protobuf==3.9.0
PyInstaller==3.5
python-dateutil==2.8.0
pytz==2019.1
pywin32-ctypes==0.2.0
PyYAML==5.1.2
scipy==1.3.0
six==1.12.0
tb-nightly==1.14.0a20190301
tensorflow==2.0.0a0
termcolor==1.1.0
tf-estimator-nightly==1.14.0.dev2019030115
Werkzeug==0.15.5
Very minimal code to reproduce the error:
from tensorflow import keras
model = keras.load_model(`./model.hf5`)
Please help me. This is plaguing me now for days. Thanks!
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/b4426f10-8d84-4051-a0f0-d39358dc249b%40googlegroups.com.