You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PyCharm运行配置中PySide环境变量不生效,无法检测缺失Slot装饰器

PyCharm中配置Qt for Python槽函数诊断环境变量无效问题

我尝试按照Qt for Python文档中信号与槽章节的末尾说明,启用缺失Slot装饰器的诊断功能。在终端手动设置环境变量后运行程序,该功能可正常激活;但在PyCharm的运行配置中设置相同环境变量后,功能却无法生效。

以下是我的测试代码:

import random
import sys

from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QLabel, QPushButton, QVBoxLayout, QWidget


class MyWidget(QWidget):
    def __init__(self):
        super().__init__()

        self.hello = ["Hallo Welt", "Hei maailma", "Hola Mundo", "Привет мир"]

        self.button = QPushButton("Click me!")
        self.text = QLabel("Hello World", alignment=Qt.AlignmentFlag.AlignCenter)

        self.layout = QVBoxLayout(self)
        self.layout.addWidget(self.text)
        self.layout.addWidget(self.button)

        self.button.clicked.connect(self.magic)

    def magic(self):
        self.text.setText(random.choice(self.hello))


if __name__ == "__main__":
    app = QApplication([])

    widget = MyWidget()
    widget.resize(800, 600)
    widget.show()

    sys.exit(app.exec())

这是我在PyCharm运行配置中设置的环境变量截图:
运行配置环境变量截图

请问我哪里操作出错了?

内容的提问来源于stack exchange,提问作者Intolighter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 10:24:54