Just a thought: when you say you have tried specifying hidden imports, you've tried 'tensorflow.keras'?  I had a very similar problem, one relying partly on dynamic import PyInstaller couldn't figure out.  Adding the path name as a hidden import solved the issue, told it to package my dynamic module with no issue.

I hope things are that simple.


Cheers,


Vincent

On 8/4/2019 2:05 PM, renscy wrote:
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:
|
importtensorflow astf

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 Limitedtf.compat.v2.summary API due to missing TensorBoardinstallation Limitedtf.summary API due to missing TensorBoardinstallation Traceback(most recent call last):File"main.py",line 4,in<module>frommodules.model importmodels 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,inexec_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,inload_models     model =tf.keras.models.load_model(os.path.join('.','models',('m'+str(i)+'eF.h5')))AttributeError:module'tensorflow'has noattribute 'keras'[11288]Failedto execute script main|
|

Basic requirements of my project:
|
|numpy==1.16.4opencv-python==4.1.0.25pandas==0.25.0PyInstaller==3.5tensorflow==2.0.0a0|
|

The /actual/ requirements of my project, when I use /pip freeze/:
|
|numpy==1.16.4opencv-python==4.1.0.25pandas==0.25.0PyInstaller==3.5tensorflow==2.0.0a0|
|

|


Theextended requirements (downloaded andinstalled too wheninstalling 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:
|
|fromtensorflow importkeras 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] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/b4426f10-8d84-4051-a0f0-d39358dc249b%40googlegroups.com <https://groups.google.com/d/msgid/pyinstaller/b4426f10-8d84-4051-a0f0-d39358dc249b%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
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/b25c6c2b-da79-890b-98f6-cf338ce8af2d%40gmail.com.

Reply via email to