sub = Popen(["pyinstaller", "--clean", "-F", "--windowed", "pyinstaller.spec"], env=env)
I don't want the entire folder and its dependency files. I need single exe file for my python script. Any suggestions please let me know.
I am able to generate single exe file based on the below changes in the pyinstaller.spec.
****************************************************************************
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""
This is a PyInstaller spec file.
"""
import os
from PyInstaller.building.api import PYZ, EXE, COLLECT
from PyInstaller.building.build_main import Analysis
from PyInstaller.utils.hooks import is_module_satisfies
cipher_obj = None
a = Analysis(
["qt.py"],
hookspath=["."], # To find "hook-cefpython3.py"
pathex=['E:\\Sriram\\learning\\python\\browser\\examples\\pyinstaller',],
cipher=cipher_obj,
win_private_assemblies=True,
win_no_prefer_redirects=True,
)
pyz = PYZ(a.pure,
a.zipped_data,
cipher=cipher_obj)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='cefapp',
debug=True,
strip=False,
upx=False,
console=True,
icon="../resources/wxpython.ico" )
***************************************************************************
I also made few modification qt.py to use the pyside as the default. I have also moved the qt.py file inside the pyinstaller folder. When I run using the python command, it is working fine. But when I run the exe I am getting the below error. Definitely I am missing something and I don't know what I am missing.
***************************************************************************
[0530/193129.566:ERROR:main_delegate.cc(684)] Could not load locale pak for en-US
[0530/193129.566:ERROR:main_delegate.cc(691)] Could not load cef.pak
[0530/193129.566:ERROR:main_delegate.cc(708)] Could not load cef_100_percent.pak
[0530/193129.566:ERROR:main_delegate.cc(717)] Could not load cef_200_percent.pak
[0530/193129.566:ERROR:main_delegate.cc(726)] Could not load cef_extensions.pak
[0530/193129.581:ERROR:content_client.cc(269)] No data resource available for id 20418
[0530/193129.581:ERROR:content_client.cc(269)] No data resource available for id 20419
[0530/193129.581:ERROR:content_client.cc(269)] No data resource available for id 20420
[0530/193129.581:ERROR:content_client.cc(269)] No data resource available for id 20421
[0530/193129.581:ERROR:content_client.cc(269)] No data resource available for id 20422
[0530/193129.581:ERROR:content_client.cc(269)] No data resource available for id 20417
[0530/193129.597:ERROR:extension_system.cc(72)] Failed to parse extension manifest.
LOADER: Back to parent (RC: -1073741819)
LOADER: Doing cleanup
LOADER: Freeing archive status for E:\Sriram\learning\python\browser\examples\pyinstaller\dist\cefapp.exe
****************************************************************************
| if not os.environ.get("PYINSTALLER_CEFPYTHON3_HOOK_SUCCEEDED", None): | |
| raise SystemExit("Error: Pyinstaller hook-cefpython3.py script was " | |
| "not executed or it failed") |
if not os.environ.get("PYINSTALLER_CEFPYTHON3_HOOK_SUCCEEDED", None):
raise SystemExit("Error: Pyinstaller hook-cefpython3.py script was "
"not executed or it failed")
The exe conversion completed successfully without any error. But when I ran the exe, I am facing the same problem.
As per the INFO message, the "cef.pak" & "locales/en-US.pak" are processing in the "datas". I am using the same hook file from the cefpython pyinstaller file. In the hook file, the binary variable is set as NULL.
# Include binaries
binaries = []
if getattr(sys, 'frozen', False):
tempLocation = sys._MEIPASS
libLocation = {'resources_dir_path': tempLocation, 'locales_dir_path': tempLocation + os.sep + 'locales'}
else:
libLocation = {'resources_dir_path': 'C:\Python34\Lib\site-packages\cefpython3', 'locales_dir_path': 'C:\Python34\Lib\site-packages\cefpython3\locales'}
cef.Initialize(libLocation)
After this change the application not crashed and no error in the console. But the app not loaded fully. It stops in an ideal state and not terminated. The "http://www.google.com" url not displayed in the URL tab and not in the page is not loaded in the browser also.
Console Output:
PyInstaller Bootloader 3.x
LOADER: executable is E:\Sriram\learning\python\browser\examples\pyinstaller\dist\cefapp.exe
LOADER: homepath is E:\Sriram\learning\python\browser\examples\pyinstaller\dist
LOADER: _MEIPASS2 is NULL
LOADER: archivename is E:\Sriram\learning\python\browser\examples\pyinstaller\dist\cefapp.exe
LOADER: Extracting binaries
LOADER: Executing self as child
LOADER: set _MEIPASS2 to C:\Users\sam\AppData\Local\Temp\_MEI22762
LOADER: Setting up to run child
LOADER: Creating child process
LOADER: Waiting for child process to finish...
PyInstaller Bootloader 3.x
LOADER: executable is E:\Sriram\learning\python\browser\examples\pyinstaller\dist\cefapp.exe
LOADER: homepath is E:\Sriram\learning\python\browser\examples\pyinstaller\dist
LOADER: _MEIPASS2 is C:\Users\sam\AppData\Local\Temp\_MEI22762
LOADER: archivename is E:\Sriram\learning\python\browser\examples\pyinstaller\dist\cefapp.exe
LOADER: SetDllDirectory(C:\Users\sam\AppData\Local\Temp\_MEI22762)
LOADER: Already in the child - running user's code.
LOADER: manifestpath: C:\Users\sam\AppData\Local\Temp\_MEI22762\cefapp.exe.manifest
LOADER: Activation context created
LOADER: Activation context activated
LOADER: Python library: C:\Users\sam\AppData\Local\Temp\_MEI22762\python34.dll
LOADER: Loaded functions from Python library.
LOADER: Manipulating environment (sys.path, sys.prefix)
LOADER: Pre-init sys.path is C:\Users\sam\AppData\Local\Temp\_MEI22762\base_library.zip;C:\Users\sam\AppData\Local\Temp\_MEI22762
LOADER: sys.prefix is C:\Users\sam\AppData\Local\Temp\_MEI22762
LOADER: Setting runtime options
LOADER: Bootloader option: pyi-windows-manifest-filename cefapp.exe.manifest
LOADER: Initializing python
LOADER: Overriding Python's sys.path
LOADER: Post-init sys.path is C:\Users\sam\AppData\Local\Temp\_MEI22762\base_library.zip;C:\Users\sam\AppData\Local\Temp\_MEI22762
LOADER: Setting sys.argv
LOADER: setting sys._MEIPASS
LOADER: importing modules from CArchive
LOADER: extracted struct
LOADER: callfunction returned...
LOADER: extracted pyimod01_os_path
LOADER: callfunction returned...
LOADER: extracted pyimod02_archive
LOADER: callfunction returned...
LOADER: extracted pyimod03_importers
LOADER: callfunction returned...
LOADER: Installing PYZ archive with Python modules.
LOADER: PYZ archive: out00-PYZ.pyz
LOADER: Running pyiboot01_bootstrap.py
LOADER: Running pyi_rth_qt4plugins.py
LOADER: Running qt.py
[qt.py] CEF Python 57.0
[qt.py] Python 3.4.4 64bit
[qt.py] PySide 1.2.2 (qt 4.8.5)
I have created seperate onefile exe & bundle exe and compared file by file. All the supported files are in the onefile exe temp folder.
if getattr(sys, 'frozen', False):
appSettings = {
'resources_dir_path': sys._MEIPASS,
'locales_dir_path': sys._MEIPASS + os.sep + 'locales',
'browser_subprocess_path': sys._MEIPASS + os.sep + 'subprocess.exe',
}
else:
appSettings = {
'resources_dir_path': 'C:\Python34\Lib\site-packages\cefpython3',
'locales_dir_path': 'C:\Python34\Lib\site-packages\cefpython3\locales'
}
cef.Initialize(appSettings)
I have missed the "subprocess.exe" in the "browser_subprocess_path". Thanks for your help Czarek. It is now working.