1

我有 PyQt 的代码:

import sys

from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *

def main():
    page = raw_input('Escriu una web: ')
    app = QApplication(sys.argv)
    view = QWebView()
    view.settings().setAttribute(QWebSettings.JavascriptEnabled, True)
    view.load(QUrl(page))
    view.setWindowTitle('Titanicus 0.1')
    view.show()
    app.exec_()

if __name__ == '__main__':
    main()

我的 setup.py 文件是这样的:

    import sys
    from cx_Freeze import setup, Executable

    setup(
        name = "On Dijkstra's Algorithm",
        version = "3.1",
        description = "A Dijkstra's Algorithm help tool.",
        executables = [Executable("nautilus.py")])

我已经建立了文件夹,但是当我尝试打开新的 exe 文件时,它返回了该错误:

File "ExtensionLoader_PyQt4_QtGui.py", line 11, in <module>
ImportError: No module named atexit

请帮忙!

4

2 回答 2

0

尝试这样的事情:

#!/usr/bin/env python
#-*- coding:utf-8 -*-

from PyQt4 import QtGui, QtCore, QtWebKit, QtNetwork

class myWindow(QtWebKit.QWebView):
    def __init__(self, parent=None):
        super(myWindow, self).__init__(parent)
        self.setWindowTitle('Titanicus 0.1')
        self.settings().setAttribute(QtWebKit.QWebSettings.JavascriptEnabled, True)

        page = raw_input('Escriu una web: ')
        self.load(QtCore.QUrl(page))

if __name__ == "__main__":
    import  sys

    app  = QtGui.QApplication(sys.argv)
    main = myWindow()
    main.show()
    sys.exit(app.exec_())
于 2012-12-31T02:39:40.967 回答
0

我会尝试添加options = {"build_exe" : {"includes" : "atexit" }}setup.py

参考。https://bitbucket.org/reclosedev/cx_freeze/src/f3cacc2fd45a/samples/PyQt4/setup.py

于 2012-12-29T12:18:12.697 回答