Pyinstaller unable to pack Tensorflow

Hey guys Im trying to make a run file or an executable for one of my codes on the jetson tx2, using libraries like argparse, imutils, cv2, numpy and Tensorflow and Keras.

When i run the Pyinstaller command to make an executable. everything runs alright. but when I try to run the executable it gives me this error.

Traceback (most recent call last):
File “detect_smile.py”, line 6, in
File “/home/husein/.local/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”, line 493, in exec_module
exec(bytecode, module.dict)
File “tensorflow/init.py”, line 101, in
File “/home/husein/.local/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”, line 493, in exec_module
exec(bytecode, module.dict)
File “tensorflow_core/init.py”, line 28, in
File “tensorflow/init.py”, line 50, in getattr
File “tensorflow/init.py”, line 44, in _load
File “importlib/init.py”, line 126, in import_module
ModuleNotFoundError: No module named ‘tensorflow_core.python’
[13007] Failed to execute script detect_smile

I’m very new to the programming and embedded systems environment so I don’t quite understand what’s happening. if someone could tell me whats happening that would be a lot of help!

Hi,

It looks like there are some dependency issue on pyinstaller+TensorFlow.

May I know which TensorFlow package do you install first?
Thanks.

Sorry for the extremely late reply, but I’ve been stuck on this problem for quite a while now, I do not understand why tensorflow is being so problematic and is unwilling to be packed by pyinstaller, I’m copy pasting the warnings that the terminal outputs everytime I try to run the packager.

husein@husein-desktop:~/Desktop/smile_detection$ python3 /home/husein/.local/bin/pyinstaller --additional-hooks-dir=hooks --onefile detect_smile.py

190 INFO: PyInstaller: 4.1.dev0
191 INFO: Python: 3.6.9
193 INFO: Platform: Linux-4.9.140-tegra-aarch64-with-Ubuntu-18.04-bionic
194 INFO: wrote /home/husein/Desktop/smile_detection/detect_smile.spec
199 INFO: UPX is not available.
203 INFO: Extending PYTHONPATH with paths
[’/home/husein/Desktop/smile_detection’, ‘/home/husein/Desktop/smile_detection’]
283 INFO: checking Analysis
283 INFO: Building Analysis because Analysis-00.toc is non existent
283 INFO: Initializing module dependency graph…
290 INFO: Caching module graph hooks…
297 WARNING: Several hooks defined for module ‘tensorflow’. Please take care they do not conflict.
326 INFO: Analyzing base_library.zip …
11871 INFO: Caching module dependency graph…
12173 INFO: running Analysis Analysis-00.toc
12258 INFO: Analyzing /home/husein/Desktop/smile_detection/detect_smile.py
12581 INFO: Processing pre-find module path hook distutils from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py’.
12586 INFO: distutils: retargeting to non-venv dir ‘/usr/lib/python3.6’
12681 INFO: Processing pre-find module path hook site from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_find_module_path/hook-site.py’.
12682 INFO: site: retargeting to fake-dir ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/fake-modules’
20001 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-setuptools.extern.six.moves.py’.
31827 INFO: Processing pre-safe import module hook six.moves from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-six.moves.py’.
84795 INFO: Processing module hooks…
84796 INFO: Loading module hook ‘hook-tensorflow.py’ from ‘/home/husein/Desktop/smile_detection/hooks’…
84947 INFO: Determining a mapping of distributions to packages…
126388 WARNING: Unable to find package for requirement grpcio from package tensorflow.
126389 WARNING: Unable to find package for requirement absl-py from package tensorflow.
126389 WARNING: Unable to find package for requirement google-pasta from package tensorflow.
126389 WARNING: Unable to find package for requirement protobuf from package tensorflow.
126389 WARNING: Unable to find package for requirement termcolor from package tensorflow.
126389 WARNING: Unable to find package for requirement six from package tensorflow.
126389 INFO: Packages required by tensorflow:
[‘keras_applications’, ‘opt_einsum’, ‘keras_preprocessing’, ‘gast’, ‘numpy’, ‘wrapt’, ‘astor’, ‘tensorflow_estimator’, ‘wheel’, ‘tensorboard’]
126491 WARNING: Unable to copy metadata for tensorflow_core: The ‘tensorflow_core’ distribution was not found and is required by the application
2020-09-04 10:54:15.375576: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.2
WARNING:tensorflow:Deprecation warnings have been disabled. Set TF_ENABLE_DEPRECATION_WARNINGS=1 to re-enable them.
Traceback (most recent call last):
File “”, line 41, in
File “”, line 36, in walk_packages
File “”, line 20, in walk_packages
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/contrib/fused_conv/init.py”, line 22, in
from tensorflow.contrib.fused_conv.python.ops.fused_conv2d_bias_activation_op import *
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/contrib/fused_conv/init.py”, line 22, in
from tensorflow.contrib.fused_conv.python.ops.fused_conv2d_bias_activation_op import *
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/contrib/fused_conv/python/ops/fused_conv2d_bias_activation_op.py”, line 26, in
resource_loader.get_path_to_datafile("_fused_conv2d_bias_activation_op.so"))
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/contrib/util/loader.py”, line 56, in load_op_library
ret = load_library.load_op_library(path)
File “/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/load_library.py”, line 61, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /usr/local/lib/python3.6/dist-packages/tensorflow_core/contrib/fused_conv/python/ops/_fused_conv2d_bias_activation_op.so: undefined symbol: _ZN10tensorflow7functor10NHWCToNCHWIN5Eigen9GpuDeviceEfLi4EEclERKS3_NS2_9TensorMapINS2_6TensorIKfLi4ELi1ElEELi16ENS2_11MakePointerEEENS7_INS8_IfLi4ELi1ElEELi16ESB_EE
145077 WARNING: Unable to determine requirements for tensorflow_core: The ‘tensorflow_core’ distribution was not found and is required by the application
145792 INFO: Packages required by astor:

148700 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.estimator.tpu” not found!
149914 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.estimator” not found!
149915 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.callbacks” not found!
157593 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.constraints” not found!
157594 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets” not found!
158431 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.xception” not found!
158432 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.densenet” not found!
161681 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.losses” not found!
161853 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.optimizers.schedules” not found!
162093 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications” not found!
162943 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.backend” not found!
163118 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.backend” not found!
163423 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.resnet_v2” not found!
164251 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets” not found!
164690 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.layers.experimental” not found!
165856 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.estimator.experimental” not found!
165857 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.nasnet” not found!
166278 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets.mnist” not found!
166279 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.preprocessing” not found!
166547 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.layers” not found!
166791 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.imagenet_utils” not found!
166882 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.inception_resnet_v2” not found!
166883 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.premade” not found!
167774 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.preprocessing.sequence” not found!
167822 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.inception_v3” not found!
167833 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.estimator” not found!
168137 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.activations” not found!
168349 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets.fashion_mnist” not found!
168349 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.models” not found!
168514 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.vgg19” not found!
168584 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.layers.experimental” not found!
168684 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.vgg16” not found!
168959 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.metrics” not found!
168960 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.estimator” not found!
169773 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.resnet_v2” not found!
170087 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets.reuters” not found!
170088 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.preprocessing.image” not found!
170820 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.estimator.inputs” not found!
171007 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.wrappers.scikit_learn” not found!
171845 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.estimator.export” not found!
172040 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.models” not found!
172041 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.initializers” not found!
172157 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.mobilenet” not found!
173004 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.nasnet” not found!
173329 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.constraints” not found!
173336 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.imagenet_utils” not found!
173441 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.initializers” not found!
173442 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.regularizers” not found!
173635 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.resnet50” not found!
173635 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.wrappers.scikit_learn” not found!
173667 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.mobilenet_v2” not found!
173975 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.v2” not found!
175133 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.estimator.experimental” not found!
175199 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.estimator.inputs” not found!
175842 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.utils” not found!
175939 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.layers” not found!
176356 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets.imdb” not found!
177025 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.optimizers.schedules” not found!
177426 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.xception” not found!
177817 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.mixed_precision.experimental” not found!
177818 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.estimator.export” not found!
177833 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.mixed_precision” not found!
177997 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.v1” not found!
178082 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets.mnist” not found!
178660 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.preprocessing.text” not found!
179253 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets.boston_housing” not found!
179469 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.utils” not found!
180701 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.metrics” not found!
180843 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications” not found!
180891 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.premade” not found!
180987 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.inception_resnet_v2” not found!
181473 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.callbacks” not found!
181474 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.mixed_precision” not found!
181595 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.vgg16” not found!
181759 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets.cifar100” not found!
182422 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets.boston_housing” not found!
182423 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets.cifar100” not found!
182759 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets.reuters” not found!
184012 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.resnet” not found!
184352 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.densenet” not found!
184934 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.experimental” not found!
184973 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets.cifar10” not found!
184984 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.optimizers” not found!
185010 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.experimental” not found!
185423 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.datasets.fashion_mnist” not found!
185424 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets.imdb” not found!
185425 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras” not found!
185425 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.estimator.tpu.experimental” not found!
185607 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.losses” not found!
186369 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.mixed_precision.experimental” not found!
186990 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.preprocessing” not found!
187742 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.estimator” not found!
188227 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.optimizers” not found!
188254 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.inception_v3” not found!
188358 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.wrappers” not found!
188656 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.preprocessing.text” not found!
188692 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras” not found!
189052 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.resnet” not found!
189163 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.mobilenet” not found!
189164 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.preprocessing.image” not found!
189534 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.resnet50” not found!
189648 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.wrappers” not found!
191129 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.datasets.cifar10” not found!
191135 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.applications.vgg19” not found!
192365 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.activations” not found!
192410 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.preprocessing.sequence” not found!
192941 WARNING: Hidden import “tensorflow_core._api.v1.compat.v2.keras.regularizers” not found!
193274 WARNING: Hidden import “tensorflow_core._api.v1.compat.v1.keras.applications.mobilenet_v2” not found!
193307 INFO: Loading module hook ‘hook-astor.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks’…
193320 INFO: Loading module hook ‘hook-lxml.etree.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks’…
193322 INFO: Loading module hook ‘hook-cv2.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks’…
193325 INFO: Loading module hook ‘hook-certifi.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks’…
193332 INFO: Loading module hook ‘hook-PyQt5.QtCore.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
193608 INFO: Loading module hook ‘hook-matplotlib.backends.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
195869 INFO: Matplotlib backend “GTK3Agg”: added
197420 INFO: Matplotlib backend “GTK3Cairo”: added
198108 INFO: Matplotlib backend “MacOSX”: ignored
cannot import name ‘_macosx’
198802 INFO: Matplotlib backend “nbAgg”: ignored
No module named ‘IPython’
-c:12: MatplotlibDeprecationWarning:
The matplotlib.backends.backend_qt4agg backend was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
200359 INFO: Matplotlib backend “Qt4Agg”: added
-c:12: MatplotlibDeprecationWarning:
The matplotlib.backends.backend_qt4cairo backend was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
202257 INFO: Matplotlib backend “Qt4Cairo”: added
203569 INFO: Matplotlib backend “Qt5Agg”: added
205395 INFO: Matplotlib backend “Qt5Cairo”: added
206151 INFO: Matplotlib backend “TkAgg”: ignored
No module named ‘tkinter’
206841 INFO: Matplotlib backend “TkCairo”: ignored
No module named ‘tkinter’
207561 INFO: Matplotlib backend “WebAgg”: ignored
Traceback (most recent call last):
File “/home/husein/.local/lib/python3.6/site-packages/matplotlib/backends/backend_webagg.py”, line 27, in
import tornado
ModuleNotFoundError: No module named ‘tornado’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “”, line 12, in
File “/home/husein/.local/lib/python3.6/site-packages/matplotlib/backends/backend_webagg.py”, line 29, in
raise RuntimeError(“The WebAgg backend requires Tornado.”) from err
RuntimeError: The WebAgg backend requires Tornado.
208723 INFO: Matplotlib backend “WX”: ignored
No module named ‘wx’
209344 INFO: Matplotlib backend “WXAgg”: ignored
No module named ‘wx’
209961 INFO: Matplotlib backend “WXCairo”: ignored
No module named ‘wx’
210723 INFO: Matplotlib backend “agg”: added
211488 INFO: Matplotlib backend “cairo”: added
212633 INFO: Matplotlib backend “pdf”: added
213839 INFO: Matplotlib backend “pgf”: added
214615 INFO: Matplotlib backend “ps”: added
215418 INFO: Matplotlib backend “svg”: added
216576 INFO: Matplotlib backend “template”: added
217325 INFO: Processing pre-safe import module hook gi.repository.Gio from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.Gio.py’.
217329 INFO: Processing pre-safe import module hook gi.repository.GLib from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.GLib.py’.
217330 INFO: Processing pre-safe import module hook gi.repository.GObject from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.GObject.py’.
217332 INFO: Processing pre-safe import module hook gi.repository.Gtk from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.Gtk.py’.
217334 INFO: Processing pre-safe import module hook gi.repository.Gdk from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.Gdk.py’.
218531 INFO: Loading module hook ‘hook-scipy.stats._stats.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
218534 INFO: Loading module hook ‘hook-xml.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
218537 INFO: Loading module hook ‘hook-PyQt5.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
247307 WARNING: Hidden import “PyQt5.sip” not found!
247307 INFO: Loading module hook ‘hook-sqlite3.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
247472 INFO: Loading module hook ‘hook-scipy.special._ellip_harm_2.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
247475 INFO: Loading module hook ‘hook-gi.repository.Gdk.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
247994 INFO: Processing pre-safe import module hook gi.repository.cairo from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.cairo.py’.
247999 INFO: Processing pre-safe import module hook gi.repository.Pango from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.Pango.py’.
248002 INFO: Processing pre-safe import module hook gi.repository.GdkPixbuf from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.GdkPixbuf.py’.
248004 INFO: Loading module hook ‘hook-gi.repository.GLib.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
251807 INFO: Loading module hook ‘hook-sysconfig.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
251833 INFO: Loading module hook ‘hook-gi.repository.Pango.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
252242 INFO: Loading module hook ‘hook-gi.repository.Gtk.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283509 INFO: Processing pre-safe import module hook gi.repository.xlib from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.xlib.py’.
283513 INFO: Processing pre-safe import module hook gi.repository.Atk from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.Atk.py’.
283522 INFO: Loading module hook ‘hook-xml.dom.domreg.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283523 INFO: Loading module hook ‘hook-encodings.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283696 INFO: Loading module hook ‘hook-PyQt5.QtGui.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283818 INFO: Loading module hook ‘hook-scipy.special._ufuncs.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283822 INFO: Loading module hook ‘hook-scipy.sparse.csgraph.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283834 INFO: Loading module hook ‘hook-distutils.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283837 INFO: Loading module hook ‘hook-numpy.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283839 INFO: Loading module hook ‘hook-xml.etree.cElementTree.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
283840 INFO: Loading module hook ‘hook-pandas.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
286046 INFO: Loading module hook ‘hook-gi.repository.GObject.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
286500 WARNING: Hidden import “gi._gobject” not found!
286501 INFO: Loading module hook ‘hook-gi.repository.Gio.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
287127 INFO: Loading module hook ‘hook-numpy.core.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
287140 INFO: Loading module hook ‘hook-PIL.Image.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
288347 INFO: Loading module hook ‘hook-PyQt5.QtWidgets.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
288570 INFO: Loading module hook ‘hook-gi.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
288574 INFO: Loading module hook ‘hook-pkg_resources.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
290458 INFO: Processing pre-safe import module hook win32com from ‘/home/husein/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/pre_safe_import_module/hook-win32com.py’.
290673 WARNING: Hidden import “pkg_resources.py2_warn” not found!
291014 WARNING: Hidden import “pkg_resources.markers” not found!
291025 INFO: Excluding import ‘main
291036 INFO: Removing import of main from module pkg_resources
291037 INFO: Loading module hook ‘hook-pytz.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
291045 INFO: Loading module hook ‘hook-PIL.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
291057 INFO: Excluding import ‘PySide’
291074 INFO: Excluding import ‘PyQt4’
291091 INFO: Excluding import ‘PyQt5’
291104 INFO: Removing import of PyQt5.QtCore from module PIL.ImageQt
291105 INFO: Removing import of PyQt5.QtGui from module PIL.ImageQt
291109 INFO: Excluding import ‘tkinter’
291124 INFO: Removing import of tkinter from module PIL.ImageTk
291126 INFO: Import to be excluded not found: ‘FixTk’
291126 INFO: Loading module hook ‘hook-gi.repository.Atk.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
291654 INFO: Loading module hook ‘hook-setuptools.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
293722 INFO: Loading module hook ‘hook-scipy.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
293726 INFO: Loading module hook ‘hook-scipy.linalg.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
293728 INFO: Loading module hook ‘hook-matplotlib.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
294316 INFO: Loading module hook ‘hook-lib2to3.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
294481 INFO: Loading module hook ‘hook-gi.repository.GdkPixbuf.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
295197 INFO: Processing pre-safe import module hook gi.repository.GModule from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-gi.repository.GModule.py’.
295200 INFO: Loading module hook ‘hook-gi.repository.cairo.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
295569 INFO: Loading module hook ‘hook-gi.repository.xlib.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
296006 INFO: Loading module hook ‘hook-packaging.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
296009 INFO: Loading module hook ‘hook-PIL.SpiderImagePlugin.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
296027 INFO: Import to be excluded not found: ‘FixTk’
296028 INFO: Excluding import ‘tkinter’
296039 INFO: Loading module hook ‘hook-gi.repository.GModule.py’ from ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks’…
297645 INFO: Looking for ctypes DLLs
297961 WARNING: library user32 required via ctypes not found
298154 INFO: Analyzing run-time hooks …
298221 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py’
298228 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py’
298239 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pyqt5.py’
298244 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_gdkpixbuf.py’
298249 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_gtk.py’
298252 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_glib.py’
298255 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_gio.py’
298258 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_gi.py’
298261 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_mplconfig.py’
298264 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_mpldata.py’
298266 INFO: Including run-time hook ‘/home/husein/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/rthooks/pyi_rth_certifi.py’
298399 INFO: Looking for dynamic libraries
310790 INFO: Looking for eggs
310791 INFO: Python library not in binary dependencies. Doing additional searching…
310853 INFO: Using Python library /usr/lib/aarch64-linux-gnu/libpython3.6m.so.1.0
310968 INFO: Warnings written to /home/husein/Desktop/smile_detection/build/detect_smile/warn-detect_smile.txt
311718 INFO: Graph cross-reference written to /home/husein/Desktop/smile_detection/build/detect_smile/xref-detect_smile.html
318209 INFO: checking PYZ
318210 INFO: Building PYZ because PYZ-00.toc is non existent
318210 INFO: Building PYZ (ZlibArchive) /home/husein/Desktop/smile_detection/build/detect_smile/PYZ-00.pyz
325689 INFO: Building PYZ (ZlibArchive) /home/husein/Desktop/smile_detection/build/detect_smile/PYZ-00.pyz completed successfully.
326280 INFO: checking PKG
326280 INFO: Building PKG because PKG-00.toc is non existent
326280 INFO: Building PKG (CArchive) PKG-00.pkg
865944 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
872222 INFO: Bootloader /home/husein/.local/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit-aarch/run
872222 INFO: checking EXE
872222 INFO: Building EXE because EXE-00.toc is non existent
872222 INFO: Building EXE from EXE-00.toc
872225 INFO: Appending archive to ELF section in EXE /home/husein/Desktop/smile_detection/dist/detect_smile
880636 INFO: Building EXE from EXE-00.toc completed successfully.
husein@husein-desktop:~/Desktop/smile_detection$

-I had seen a solution in which they used a hooks folder to try and solve their issue on github but that did not work for me either. And after i pack this object when I run it it says :

2020-09-04 11:31:07.315453: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.2
WARNING:tensorflow:Deprecation warnings have been disabled. Set TF_ENABLE_DEPRECATION_WARNINGS=1 to re-enable them.
Traceback (most recent call last):
File “detect_smile.py”, line 6, in
File “/home/husein/.local/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”, line 493, in exec_module
exec(bytecode, module.dict)
File “tensorflow/init.py”, line 101, in
File “/home/husein/.local/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”, line 493, in exec_module
exec(bytecode, module.dict)
File “tensorflow_core/init.py”, line 28, in
File “tensorflow/init.py”, line 50, in getattr
File “tensorflow/init.py”, line 44, in _load
File “importlib/init.py”, line 126, in import_module
File “/tmp/_MEImyoMor/tensorflow_core/python/init.py”, line 63, in
from tensorflow.python.framework.framework_lib import * # pylint: disable=redefined-builtin
File “/tmp/_MEImyoMor/tensorflow_core/python/framework/framework_lib.py”, line 25, in
from tensorflow.python.framework.ops import Graph
File “/tmp/_MEImyoMor/tensorflow_core/python/framework/ops.py”, line 58, in
from tensorflow.python.platform import app
File “/tmp/_MEImyoMor/tensorflow_core/python/platform/app.py”, line 23, in
from absl.app import run as _run
ModuleNotFoundError: No module named ‘absl.app’
[13235] Failed to execute script detect_smile

I had first installed tensorflow 2.0 which I later downgraded to Tensorflow 1.15 and I am running Keras 2.0 with it.

So, for some context I was using this solution from github to try and address my problem-

But then It did not work for me, pyinstaller stil could not find the tensorflow packages.

Now when I run the pyinstaller I see that it’s accessing the site packages inside (.local/lib/python) but the tensorflow and keras packages which are not being packed are inside dist-packages inside /usr/local/lib/python3.6

Please do let me know if anyone can help me figure out this stuff thanks!

I’d really appreciate if someone could maybe give in their inputs here, I’ve been trying to get this executable to identify tensorflow but it does not

Hi,

We give it a try and pyinstaller can work on our environment.
Here are the detail for your reference.

Environment

  • JetPack4.4
  • TensorFlow

test.py

import tensorflow as tf
  
print(tf.__version__)

Command:

$ pip3 install pyinstaller
$ pyinstaller test.py 

Log:

93 INFO: PyInstaller: 4.0
93 INFO: Python: 3.6.9
95 INFO: Platform: Linux-4.9.140-tegra-aarch64-with-Ubuntu-18.04-bionic
96 INFO: wrote /home/nvidia/test.spec
100 INFO: UPX is not available.
104 INFO: Extending PYTHONPATH with paths
['/home/nvidia', '/home/nvidia']
127 INFO: checking Analysis
127 INFO: Building Analysis because Analysis-00.toc is non existent
127 INFO: Initializing module dependency graph...
131 INFO: Caching module graph hooks...
148 INFO: Analyzing base_library.zip ...
8088 INFO: Caching module dependency graph...
8290 INFO: running Analysis Analysis-00.toc
8354 INFO: Analyzing /home/nvidia/test.py
8613 INFO: Processing pre-find module path hook distutils from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
8614 INFO: distutils: retargeting to non-venv dir '/usr/lib/python3.6'
8697 INFO: Processing pre-find module path hook site from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_find_module_path/hook-site.py'.
8698 INFO: site: retargeting to fake-dir '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/fake-modules'
22138 INFO: Processing pre-safe import module hook six.moves from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-six.moves.py'.
51596 INFO: Processing module hooks...
51597 INFO: Loading module hook 'hook-tensorflow.py' from '/home/nvidia/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
51598 INFO: Loading module hook 'hook-lxml.etree.py' from '/home/nvidia/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
51600 INFO: Loading module hook 'hook-sqlite3.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
51727 INFO: Loading module hook 'hook-lib2to3.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
51762 INFO: Loading module hook 'hook-scipy.special._ellip_harm_2.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
51763 INFO: Loading module hook 'hook-setuptools.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53203 INFO: Loading module hook 'hook-numpy.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53204 INFO: Loading module hook 'hook-scipy.stats._stats.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53207 INFO: Loading module hook 'hook-scipy.linalg.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53209 INFO: Loading module hook 'hook-scipy.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53211 INFO: Loading module hook 'hook-sysconfig.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53228 INFO: Loading module hook 'hook-distutils.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53230 INFO: Loading module hook 'hook-scipy.sparse.csgraph.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
53238 INFO: Loading module hook 'hook-pandas.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
54750 INFO: Loading module hook 'hook-scipy.special._ufuncs.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
54753 INFO: Loading module hook 'hook-pkg_resources.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
55622 INFO: Processing pre-safe import module hook win32com from '/home/nvidia/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/pre_safe_import_module/hook-win32com.py'.
56058 WARNING: Hidden import "pkg_resources.py2_warn" not found!
56059 WARNING: Hidden import "pkg_resources.markers" not found!
56064 INFO: Excluding import '__main__'
56068 INFO:   Removing import of __main__ from module pkg_resources
56069 INFO: Loading module hook 'hook-xml.dom.domreg.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
56070 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
56071 INFO: Loading module hook 'hook-pytz.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
56076 INFO: Loading module hook 'hook-xml.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
56077 INFO: Loading module hook 'hook-encodings.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
56216 INFO: Loading module hook 'hook-numpy.core.py' from '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
56324 INFO: Looking for ctypes DLLs
56573 WARNING: library user32 required via ctypes not found
56721 INFO: Analyzing run-time hooks ...
56768 INFO: Including run-time hook '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py'
56772 INFO: Including run-time hook '/home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
56834 INFO: Looking for dynamic libraries
60921 INFO: Looking for eggs
60922 INFO: Python library not in binary dependencies. Doing additional searching...
60997 INFO: Using Python library /usr/lib/aarch64-linux-gnu/libpython3.6m.so.1.0
61058 INFO: Warnings written to /home/nvidia/build/test/warn-test.txt
61379 INFO: Graph cross-reference written to /home/nvidia/build/test/xref-test.html
61476 INFO: checking PYZ
61476 INFO: Building PYZ because PYZ-00.toc is non existent
61477 INFO: Building PYZ (ZlibArchive) /home/nvidia/build/test/PYZ-00.pyz
65070 INFO: Building PYZ (ZlibArchive) /home/nvidia/build/test/PYZ-00.pyz completed successfully.
65135 INFO: checking PKG
65136 INFO: Building PKG because PKG-00.toc is non existent
65136 INFO: Building PKG (CArchive) PKG-00.pkg
65221 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
65225 INFO: Bootloader /home/nvidia/.local/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit-aarch/run
65226 INFO: checking EXE
65226 INFO: Building EXE because EXE-00.toc is non existent
65226 INFO: Building EXE from EXE-00.toc
65227 INFO: Appending archive to ELF section in EXE /home/nvidia/build/test/test
65262 INFO: Building EXE from EXE-00.toc completed successfully.
65267 INFO: checking COLLECT
65267 INFO: Building COLLECT because COLLECT-00.toc is non existent
65267 INFO: Building COLLECT COLLECT-00.toc
65896 INFO: Building COLLECT COLLECT-00.toc completed successfully.

Thanks.

@AastaLLL May I ask what your Tensorflow version is? Thanks.