我想編譯PyQt程序使用PyInstaller 1.5。當我使用--onedir(默認設置)時,以下兩個程序都可以正常工作,但是這會創建相當大的程序。我想用--onefile選項,但是當我運行創建onefile應用程序,我得到的錯誤:PyInstaller錯誤與PyQt時試圖建立--onefile
import sys
from PyQt4 import QtCore, QtGui
app =QtGui.QApplication(sys.argv)
window =QtGui.QMainWindow()
window.setCentralWidget(QtGui.QLabel("Hello"))
window.show()
sys.exit(app.exec_())
這:
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "pyinstaller/PyInstaller/loader/iu.py", line 468, in importHook
raise ImportError("No module named %s" % fqname)
ImportError: No module named PyQt4.QtCore
這兩者出現此錯誤
import sys
import PyQt4.QtCore, PyQt4.QtGui
app = PyQt4.QtGui.QApplication(sys.argv)
window = PyQt4.QtGui.QMainWindow()
window.setCentralWidget(PyQt4.QtGui.QLabel("Hello"))
window.show()
sys.exit(app.exec_())
有沒有人有任何想法?
我試圖找到我的例子中的.spec文件爲PyQt的構建我沒有在Linux中而回。我無法找到它,但我認爲我必須對spec文件中的Analysis()定義做些什麼。也許我錯了,我所做的只是'從PyQt4導入QtCore,QtGui'導入語法。 – jdi
事實上,你可以隨時在spec文件中加入'PyQt4',這將確保pyinstaller將它包含進去。 –
您介意如何將PyQt4(或任何其他大型軟件包)添加到spec文件中,讓我介紹一下嗎?恐怕這些文檔不夠清晰,無法理解我在做什麼。 – taynaron