在python编译的exe文件中使用QWebEngineView时出现错误“网络服务崩溃,重新启动服务”

Error "Network service crashed, restarting service" using QWebEngineView in python compiled exe file

提问人:J Jack 提问时间:7/14/2023 最后编辑:J Jack 更新时间:7/15/2023 访问量:132

问:

然后我从python运行,我的代码工作正常。但?然后我运行编译的执行文件,使用cx_freeze,我得到这个错误:

ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting service.

我写了一个简单的可重复代码。在我的主程序中,我加载了一个存储在本地的 HTML。 在此示例中,我尝试了两个选项,它们都产生了相同的错误。

Python 代码:

import os, sys
from PySide2 import QtWidgets
from PySide2.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings
from PySide2.QtCore import QUrl

app = QtWidgets.QApplication(sys.argv)
view = QWebEngineView()

file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "html_example.html")

local_url = QUrl.fromLocalFile(file_path)
url = 'https://google.com'

view.load(local_url)
view.show()
sys.exit(app.exec_())

setup.py 代码 :

# setup.py
# -*- coding: utf-8 -*-
from cx_Freeze import setup, Executable


include_files   = ['icons', 'UI' ]
options = {
    'build_exe': {'include_files'              : include_files }
}

# base = "Win32GUI"
setup(
    name            = 'works',
    version         ='1.0',
    description     = 'Tools',
    executables     = [Executable(script = "QtWebEngine_example.py")],
    options=options
)

html_example.html代码:

<!DOCTYPE html>
<html>
<body>

<h2 title="I'm a header">Hello!</h2>


</body>
</html>

我什至不知道该往哪个方向寻找原因。 我使用window os,python 3.8.10,PySide2-5.15.2.1

python cx-freeze pyside2 qwebengine查看

评论


答: 暂无答案