【发布时间】:2021-09-02 11:35:54
【问题描述】:
首先,我是一名韩国学生。所以我英语不好。对不起,请原谅。
我正在使用 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 文件在同一个文件夹中)
【问题讨论】:
-
你必须用pyinstaller添加.ui文件
标签: python pyqt pyqt5 pyinstaller