找不到 sys 模块

-3 投票
0 回答
33 浏览
提问于 2025-04-12 05:57

我想开始学习如何创建菜单,所以我找到了一个脚本来测试一下。这个脚本没有错误,但它没有显示带菜单的窗口。我查找了原因,发现问题在于它找不到 sys。

这是我使用的代码:

import sys
print(sys.path)
sys.path.insert(0,'C:\anaconda3\Lib\site-packages')
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QApplication, QLabel, QMainWindow
class Window(QMainWindow):
    def _init_(self, parent=None):
        
        super()._init_(parent)
        self.setWindowTitle("Probeersel")
        self.resize(400, 200)
        self.centralWidget = QLabel("Hello")
        self.centralWidget.setAlignment(Qt.AlignHCenter | Qt.AlingVCenter)
       self.setCentralWidget(self.centralWidget)
if __name__ == "_main_":
    app = QApplication(sys.argv)
    win = Window()
    win.show()
    sys.exit(app.exec_())

我已经卸载了 Anaconda 并重新安装,但还是不行。我的保存文件放在 Anaconda 文件夹里,但还是没用。

我已经在这里找过解决方案,但还是不行 :(

0 个回答

暂无回答

撰写回答