Using pyinstaller I have created an exe from python script. The script has dependency on tensorflow. The package is created perfectly. The issue is when I run the exe.
Python 3.6.5 Pyinstaller 3.3.1 Build platform : Win 8.1 64bit Running platform Win 7 64bit
C:\Program Files\test\FaceDetectionPackageBeta1\dist\FaceDetection>FaceDetection.exe
Using TensorFlow backend.
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14,
in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_inter
nal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <modu
le>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17,
in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16,
in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 714, in load_module
ImportError: DLL load failed with error code -1073741795
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "TELFaceDetection.py", line 12, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\keras\__init__.py", line 3, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\keras\utils\__init__.py", line 6, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\keras\utils\conv_utils.py", line 9, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\keras\backend\__init__.py", line 89, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\tensorflow\__init__.py", line 24, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\tensorflow\python\__init__.py", line 49, in <module>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <modu
le>
ImportError: Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14,
in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_inter
nal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <modu
le>
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 631, in exec_module
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17,
in <module>
File "site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16,
in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
File "c:\program files\python36\lib\site-packages\PyInstaller\loader\pyimod03_
importers.py", line 714, in load_module
ImportError: DLL load failed with error code -1073741795
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
[4988] Failed to execute script TELFaceDetection
Below is the spec file
# -*- mode: python -*-
block_cipher = None
a = Analysis(['FaceDetection.py'],
pathex=['D:\\FaceDetectionSetup\\FaceDetectioPackageSource'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='FaceDetection',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='FaceDetection')
I have tried the solution in link, but that does not work either. when I execute the exe, No module named tensorflow.python.framework.load_library error is received.
How do I set the path so that relative path is picked. The same worked without any issues on Win 7 64bit desktop system.So working on one system and not on the other.Any help appreciated.
Thanks -Megha