Reputation: 163
I am trying to make .exe file from my main.py script. In my main.py file I use Kivy and Tensorflow.
I use Pyinstaller to do it like that:
pyinstaller --onefile main.py
There is no problem with Kivy, but I have problem with Tensorflow:
ImportError: cannot import name 'pywrap_tensorflow'.
I was trying to do:
pyinstaller --paths venv\Lib\site-packages\tensorflow_core\
but it didn't solve mt problem. I also tried to use cx_freeze with this setup.py file:
from cs_freeze import setup, Executable
setup(name = "main",
version = "0.1",
description = "",
executables = [Executable("main.py")])
but then I have a problem with Kivy:
ModuleNotFoundError: no module named 'kivy.weakmethod'.
I would like to ask what is the best way to create a .exe file from python script which use both Kivy and Tensorflow.
To be honest I want to create an exe file from this tutorial: https://steemit.com/utopian-io/@faad/tensorflow-image-recognition-app-in-kivy
Best regards
Upvotes: 2
Views: 2012
Reputation: 379
I solved the problem as follows.
first imported from PyInstaller.utils.hooks import collect_submodules
in my .spec
After i change my Analysis from hiddenimports = []
to hiddenimports=collect_submodules('tensorflow_core')
it' work to me
Upvotes: 1
Reputation: 885
Have you tried:
pyinstaller --onefile --paths=<path to venv site packages, e.g. U:\myPyProject\venv\Lib\site-packages> <path to main python script>
So in your case pyinstaller --onefile --paths=venv\Lib\site-packages main.py
Upvotes: 0