2

After much trying ive finally found a way to compile my Cefpython code:

import json
import urllib.request
from cefpython3 import cefpython as cef
import platform
import sys

url = "https://google.com/"

def main():
    check_versions()
    sys.excepthook = cef.ExceptHook
    cef.Initialize()
    cef.CreateBrowserSync(url=url,
                          window_title="browser")
    cef.MessageLoop()
    cef.Shutdown()

def check_versions():
    ver = cef.GetVersion()
    print("[hello_world.py] CEF Python {ver}".format(ver=ver["version"]))
    print("[hello_world.py] Chromium {ver}".format(ver=ver["chrome_version"]))
    print("[hello_world.py] CEF {ver}".format(ver=ver["cef_version"]))
    print("[hello_world.py] Python {ver} {arch}".format(
           ver=platform.python_version(),
           arch=platform.architecture()[0]))
    assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this"


if __name__ == '__main__':
    main()

(the jason and urllib.request are there so that the compilers (py2exe pyinstaller ect) dont give errors)

Using cx_Freeze but when I run the exe cx_freeze gives me this happens:

[0930/071436.905:ERROR:main_delegate.cc(710)] Could not load locale pak for en-US
[0930/071436.906:ERROR:main_delegate.cc(717)] Could not load cef.pak
[0930/071436.906:ERROR:main_delegate.cc(734)] Could not load cef_100_percent.pak
[0930/071436.906:ERROR:main_delegate.cc(743)] Could not load cef_200_percent.pak
[0930/071436.907:ERROR:main_delegate.cc(753)] Could not load cef_extensions.pak
[0930/071436.926:ERROR:content_client.cc(272)] No data resource available for id 101

(from the debug.log)

I think this is a cefpython thing but I dont know.

marshmallow
  • 33
  • 1
  • 8
  • You have to tell cxfreeze to include CEF binary files. See the pyinstaller example in the official cefpython repository for how it is done on Windows: https://github.com/cztomczak/cefpython/blob/6f5bf081fec19647e1860bb3e0f3638c02bb9d11/examples/pyinstaller/hook-cefpython3.py#L99 – Czarek Tomczak Sep 29 '18 at 21:43
  • 2
    How do i do that in cx_freeze? – marshmallow Sep 29 '18 at 22:20

0 Answers0