簡體   English   中英

嘗試使用cx_freeze將python文件轉換為可執行文件時出錯

[英]Error on trying to convert a python file into an executable with cx_freeze

我有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

請幫助!

我嘗試將options = {"build_exe" : {"includes" : "atexit" }}setup.py

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

嘗試這樣的事情:

#!/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_())

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM