[英]pyinstaller .exe file does not work after import another module
我使用 pyinstaller 從 python 文件創建了一個 exe 文件,如下所示,文件工作正常。 但是當我導入像 vtk 或其他東西的模塊時,生成的 exe 文件不起作用。 我該如何解決這個問題?
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow
from simulation import SimulationWindow
class mainwindow(QMainWindow, SimulationWindow):
def __init__(self, parent=None):
super(mainwindow, self).__init__(parent)
self.setupUi(self)
self.show()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
demowindow = mainwindow()
demowindow.show()
sys.exit(app.exec_())
使用鈎子有一種復雜的方法,不幸的是,pyinstaller 不會捕獲所有模塊。 所以你需要為此使用鈎子。
簡單的方法就是從 site-packages 復制模塊文件夾並粘貼到你的可執行文件旁邊,問題就解決了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.