解决Qt平台插件未找到和libiomp5md.dll初始化问题
This commit is contained in:
16
run.py
16
run.py
@ -2,12 +2,11 @@ from logging import getLogger, NOTSET, FileHandler, Formatter, StreamHandler, in
|
||||
from pathlib import Path
|
||||
from sys import argv
|
||||
from time import strftime, localtime, time
|
||||
|
||||
import os
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from func.Module_mainwindow import MainWindow
|
||||
|
||||
import importlib.util
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 设置日志
|
||||
@ -28,6 +27,17 @@ if __name__ == '__main__':
|
||||
getLogger('matplotlib.font_manager').disabled = True
|
||||
info("程序启动")
|
||||
|
||||
# 解决 Could not find the Qt platform plugin "windows"
|
||||
spec = importlib.util.find_spec("PySide6")
|
||||
if spec and spec.origin:
|
||||
dirname = Path(spec.origin).parent
|
||||
plugin_path = dirname / 'plugins' / 'platforms'
|
||||
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path.__str__()
|
||||
|
||||
# 解决 Error #15: Initializing libiomp5md.dll
|
||||
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
|
||||
|
||||
|
||||
app = QApplication(argv)
|
||||
app.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
|
||||
app.styleHints().setColorScheme(Qt.ColorScheme.Light) # 强制使用浅色模式
|
||||
|
||||
Reference in New Issue
Block a user