PyQt5,:pyinstaller py 到 exe 中的“_MEI”路径错误

PyQt5, : "_MEI" path errors in pyinstaller py to exe

首先,我是一名韩国学生。所以我英语不好。抱歉,请见谅。

我正在使用 PyQt5 和 pyinstaller。我使用以下代码制作了 exe 文件:pyinstaller --noconfirm --onefile --console --paths "C:/Users/jun/Desktop/lee/Programing/python/dll" --hidden-import "nbt.world" "C:/Users/jun/Desktop/lee/Programing/python/Auto_Submit_dev1.py"

但我无法执行 exe 文件并出现此错误。

我检查了很多类似的问题和答案like this,但还是不行。

下面是我的部分代码:

def resource_path(relative_path):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
        print(base_path)
    except Exception:
        base_path = os.path.abspath(".")
        


    return os.path.join(base_path, relative_path)

macUI = resource_path("autosubmit.ui")

Ui_MainWindow = uic.loadUiType(macUI)[0]

class MainDialog(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)

如何执行exe文件? (.py 正在运行,.UI 文件和 .py 文件在同一文件夹中)

你的exe文件没有找到autosubmit.ui文件 添加这个 --> --add-data="autosubmit.ui;."

pyinstaller --noconfirm --onefile --console --add-data="autosubmit.ui;." --paths "C:/Users/jun/Desktop/lee/Programing/python/dll" --hidden-import "nbt.world"  "C:/Users/jun/Desktop/lee/Programing/python/Auto_Submit_dev1.py"