简体   繁体   中英

pyinstaller .exe file does not work after import another module

I created an exe file with pyinstaller from a python file, which is shown bellow and the file worked correctly. but when i import a module like vtk or something else the generated exe file does not worked. How can i fix this issue?

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_())

there is a complicated way by using hooks, pyinstaller does not capture all the modules, unfortunately. so you need to use hooks for that.

easy way is just copy the module folder from site-packages and paste is beside your executable, problem solved

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM