I have made a GUI application that uses Tensorflow to load in a model from a .h5 file and get a prediction. The program works fine when running it from a terminal before putting it together into an application. However, when I use py2app to make the application, I get an error from tensorflow_core.
I have tried using Python3 to put the application together and get a number of other errors when doing so.
Here are my imports regarding Tensorflow (in the Bay.py file):
from tensorflow.keras import models
import tkFileDialog as filedialog
import tensorflow as tf
When I run python setup.py py2app
everything runs fine and the application is created, but when I try to open the application I get this error in the terminal:
from tensorflow_core import *
File "tensorflow_core/__init__.pyc", line 40, in <module>
ImportError: No module named tools
I have been Googling and searching for how to fix this problem for days. I tried using tensorflow, keras, and even tensorflow.keras.models as packages in the setup.py file but that don't work either. Here is my setup.py file:
from setuptools import setup
APP = ['Bay.py']
DATA_FILES = [
'Bay0.jpg',
'Bay1.jpg',
'Bay2.jpg',
'Bay3.jpg',
'Bay4.jpg',
'Bia0.jpg',
'Bia1.jpg',
'Bia2.jpg',
'Bia3.jpg',
'Bia4.jpg',
'Sun0.jpg',
'Sun1.jpg',
'Sun2.jpg',
'Sun3.jpg',
'Sun4.jpg',
'CoverPage1.jpg',
'Model/model.h5',
'Collage/img1.jpg',
'Collage/img2.jpg',
'Collage/img3.jpg',
'Collage/img4.jpg',
'Collage/img5.jpg',
'Collage/img6.jpg',
'Collage/img7.jpg',
'Collage/img8.jpg',
'Collage/img9.jpg',
'Collage/img10.jpg',
'Collage/img11.jpg',
'Collage/img12.jpg',
'Collage/img13.jpg',
'Collage/img14.jpg',
'Collage/img15.jpg',
'Collage/img16.jpg',
'Collage/img17.jpg',
'Collage/img18.jpg',
'Collage/img19.jpg',
'Collage/img20.jpg',
'Collage/img21.jpg',
'Collage/img22.jpg',
'Collage/img23.jpg',
'Collage/img24.jpg']
OPTIONS = {'argv_emulation': True,
'iconfile':'Bay3.icns',
'packages':['tensorflow','keras']}
setup(
app=APP,
name = "App",
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)