Reputation: 103
I try to deploy a model with pyinstaller and when i run it i get the following error.
ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_internal'
Tensorflow 1.7.0
cudnn64_7
CUDA 9.0
Python 3.6
Upvotes: 5
Views: 5880
Reputation: 45
Adding the _pywrap_tensorflow_internal.pyd
as a binary file when compiling using pyinstaller
I am using Tensorflow 2.10, Python 3.10 and Pyinstaller 5.13.0. Here is what I have done:
In the .spec
file,
a = Analysis(
['test.py'],
pathex=[],
binaries=[('path_to_tensorflow_python_folder\_pywrap_tensorflow_internal.pyd', '.')],
...
)
Upvotes: 0
Reputation: 41
( Workaround for Python 3.5 only )
Building off of Jascha's solution, a work around is to manually fetch the file __python._pywrap_tensorflow_internal.pyd from
PathToAnaconda3/env//Lib/site-packages/tensorflow/python/__python._pywrap_tensorflow_internal.pyd
and rename it into tensorflow.python.__python._pywrap_tensorflow_internal.pyd
Then this renamed file can be moved into the exe file by :
pyinstaller -F <name of python file> --add-data "pathToFile/tensorflow.python.__python._pywrap_tensorflow_internal.pyd";.
The flag --add-data takes two arguments separated by semi colon
--add-data source_path;destination_path_inside_exe
Upvotes: 0
Reputation: 11
You can resolve this issue by simply renaming the file _pywrap_tensorflow_internal.pyd
contained in the dist folder to tensorflow.python._pywrap_tensorflow_internal.pyd
.
I still have to figure out how to tell pyinstaller the "correct" module name.
Upvotes: 1