Windows下通过py2exe使用PySide的QtWebKit

发布于 2024-10-11 02:47:10 字数 407 浏览 3 评论 0原文

我正在使用 PySide 和 Qt 在 Python 中制作一个应用程序,我需要打开一个网页,所以我使用了 QtWebKit 的 QWebView。

在我的开发机器上它工作得很好,既可以直接运行代码,也可以运行 py2exe 的输出。在“干净”的机器上(没有安装 Python 和 Qt),py2exe 的输出不会显示网页。应用程序的其余部分工作正常,没有崩溃或异常,但 QWebView 只是保持空白。

我尝试打开一个没有图像或其他内容的 URL,以防止与缺少 WebKit 插件相关的任何问题。我还尝试了一个简单的程序,仅在 QWebView 上打开 example.com 而没有其他任何内容,但它也不起作用。

有人遇到过类似的事情吗?另外,有人知道 QWebKit 是否有任何类型的“记录较少”的依赖项,py2exe 可能不会将其拉入“包”中?

I'm making an application in Python using PySide and Qt, and I need to open a webpage, so I used QtWebKit's QWebView.

On my development machine it works just fine, both running the code directly and running the output of py2exe. On a "clean" machine (no Python and no Qt installed), the output of py2exe doesn't show the webpage. The rest of the application works fine and there is no crash or exception, but the QWebView just stays blank.

I tried opening an URL without images or other stuff to prevent any problems related to missing WebKit plugins. I also tried a simple program that just opens example.com on a QWebView and nothing else, and it also didn't work.

Has anyone encountered anything similar? Also, anybody knows if QWebKit has any sort of "less documented " dependencies that py2exe might not be pulling into the "package"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一萌ing 2024-10-18 02:47:10

我会尝试 PyInstaller。它在编译 PyQT 内容时似乎工作得很好,因为它会嗅探依赖项并将它们打包(嗯,它似乎就是这样做的)。我也在用 Python 制作一个 QT 应用程序,它生成了一个可以立即运行的二进制文件。

这是一个链接: http://www.pyinstaller.org/

祝你好运!

I would try PyInstaller. It seems to work well when compiling PyQT stuff, as it sniffs dependencies and packages them too (well, it seems to do that). I was making a QT application with Python too, and it spit out a single binary that worked right off the bat.

Here's a link: http://www.pyinstaller.org/

Good luck!

日记撕了你也走了 2024-10-18 02:47:10

对于仍然遇到问题的人,请访问:

http://developer.qt。 nokia.com/wiki/Packaging_PySide_applications_on_Windows

您需要从 py2exe 端手动包含它:)

For anyone who will still have some troubles with it, there you go:

http://developer.qt.nokia.com/wiki/Packaging_PySide_applications_on_Windows

You need to include it manually from py2exe side :)

魔法少女 2024-10-18 02:47:10

在 py2exe 选项中尝试一下:

packages = ["PySide.QtNetwok"]

Try this in py2exe options:

packages = ["PySide.QtNetwok"]
苍白女子 2024-10-18 02:47:10

选择的答案实际上并没有回答问题。我遇到了类似的问题,我的应用程序使用 pyside 和 QtWebKit,在我的开发机器上工作正常,但与 py2exe 捆绑后在用户机器上却没有。

首先你的 setup.py 应该明确包含 PySide.QtNetwork: link

...
setup(
    ...
    options = {
        'py2exe': {
            ...
            'includes': ['PySide.QtNetwork'],
            ...
        }
    }
...

之后你应该打包 openSSL DLL:链接

转到 这里并获取win32openssl(您可以使用精简版)
将 libeay32.dll 和 ssleay32.dll 复制到您的项目文件夹,并将两者作为数据文件添加到 setup.py 中,如下所示:

...
setup(data_files=[('', ['libeay32.dll','ssleay32.dll'])],
...

最后您需要添加图像支持:
添加图像插件作为数据文件,最后应该是这样的:

...
setup(data_files=[("imageformats", glob(r'C:\Python27\Lib\site-packages\PySide\plugins\*.*')),('', ['libeay32.dll','ssleay32.dll'])],
...

chosen answer doesn't actually answer the question. I had a similar problem, my application uses pyside and QtWebKit, on my dev machine worked fine, on user machine after bundled with py2exe didn't.

first of all your setup.py should explicitly include PySide.QtNetwork: link

...
setup(
    ...
    options = {
        'py2exe': {
            ...
            'includes': ['PySide.QtNetwork'],
            ...
        }
    }
...

after that you should package openSSL DLLs: link

go here and get win32openssl (you may use the light version)
copy libeay32.dll and ssleay32.dll to your project folder and add both as as data files in your setup.py like this:

...
setup(data_files=[('', ['libeay32.dll','ssleay32.dll'])],
...

and finally you need to add image support:
add the image plugins as data files, at the end it should be something like this:

...
setup(data_files=[("imageformats", glob(r'C:\Python27\Lib\site-packages\PySide\plugins\*.*')),('', ['libeay32.dll','ssleay32.dll'])],
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文