经过大量尝试,我终于找到了一种编译我的Cefpython代码的方法:
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()
(有jason和urllib.request以便编译器(py2exe pyinstaller ect不会给出错误)
使用cx_Freeze,但是当我运行exe时,cx_freeze使我发生了这种情况:
[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
(来自debug.log)
我认为这是一个cefpython,但我不知道。