I am trying to convert my object detector python project into an executable file but I always get these warnings and my executable file would not run.
64422 WARNING: Hidden import "tensorflow._api.v2.compat.v1.estimator" not found!
64425 WARNING: Hidden import "tensorflow._api.v2.compat.v2.compat.v2.keras.metrics" not found!
64843 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.keras.applications.resnet50" not found!
64844 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.keras.applications.resnet" not found!
64845 WARNING: Hidden import "tensorflow._api.v2.compat.v2.compat.v2.keras.backend" not found!
64857 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.estimator.tpu" not found!
64859 WARNING: Hidden import "tensorflow._api.v2.compat.v2.compat.v1.keras.applications.mobilenet" not found!
64892 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.keras.applications.vgg19" not found!
64894 WARNING: Hidden import "tensorflow._api.v2.compat.v2.compat.v2.keras.preprocessing.text" not found!
64896 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.estimator.tpu.experimental" not found!
64899 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.keras.applications.resnet_v2" not found!
64956 WARNING: Hidden import "tensorflow._api.v2.compat.v2.compat.v1.keras.wrappers.scikit_learn" not found!
64957 WARNING: Hidden import "tensorflow._api.v2.compat.v2.compat.v2.keras.applications.resnet50" not found!
64958 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.keras.wrappers.scikit_learn" not found!
65073 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v2.keras.applications.imagenet_utils" not found!
65073 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v2.keras.datasets.cifar100" not found!
65238 WARNING: Hidden import "tensorflow._api.v2.compat.v1.compat.v1.keras.optimizers" not found!
My project structure is
- project folder
- venv
- main.py
- detect.py
Inside the detect.py
I have the following imports
import tensorflow as tf
from tensorflow.python.saved_model import tag_constants
from tensorflow.compat.v1 import ConfigProto
from tensorflow.compat.v1 import InteractiveSession
The tensorflow module
can be found in the site-packages
inside the venv
folder
The solutions that I have tried are adding the --hidden-import tensorflow
flag as said in this Question
pyinstaller --hidden-import tensorflow --onefile main.py
I have also tried this approach by creating a hooks
directory with hook-tensorflow.py
file
- project folder
- venv
- hooks
- hook-tensorflow.py
- main.py
- detect.py
hook-tensorflow.py
from PyInstaller.utils.hooks import collect_all
def hook(hook_api):
packages = [
'tensorflow'
]
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)
And then issuing this terminal command
pyinstaller --additional-hooks-dir=hooks --onefile main.py
But still, the same warning still persists and my executable file would not run.
from Hidden import Tensorflow package not found when using Pyinstaller
No comments:
Post a Comment