Trying to distribute a program that relies on tensorflow...
Using tensorflow it works nicely both as script and with pyinstaller. Using tensorflow-gpu it works as script but not with pyinstaller. The cuda and cudnn dlls have been copied into the bundle folder by pyinstaller.
I use python 3.6.5 and tensorflow 1.7.0. (Can change version if it helps...)
Error message:
Traceback (most recent call last): File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.dict) File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper File "importlib__init__.py", line 126, in import_module ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "interface.py", line 14, in File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.dict) File "site-packages\tensorflow__init__.py", line 24, in File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.dict) File "site-packages\tensorflow\python__init__.py", line 49, in File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.dict) File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in ImportError: Traceback (most recent call last): File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in File "c:\users\aleks\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.dict) File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper File "importlib__init__.py", line 126, in import_module ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace above this error message when asking for help. [10816] Failed to execute script interface
Make sure you are also packaging MSVCP140.DLL
, as missing this from the %PATH% can throw this error.
I tend to use cx_Freeze instead of pyinstaller when distributing tensorflow applications. Once you overcome the error cx_Freeze has with scipy, it's simpler overall.
Maybe this can help. I manually rename the file _pywrap_tensorflow_internal.pyd
to tensorflow.python._pywrap_tensorflow_internal.pyd
in the dist folder. Everything works.
I fixed this problem by making dirs as ".../dist/[MmyPyName]/tensorflow/python/_pywrap_tensorflow_internal.pyd"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With