[英]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.