AttributeError: 'QAction' object has no attribute 'setShortcutVisibleInContextMenu'

AttributeError: 'QAction' object has no attribute 'setShortcutVisibleInContextMenu'

我在 Windows 上使用 Spyder。

这些是我的 python 版本和模块:

PS C:\Windows\system32> python --version
Python 3.9.10
PS C:\Windows\system32> pip list
Package            Version
------------------ ---------
imageio            2.18.0
joblib             1.1.0
networkx           2.8
numpy              1.22.3
packaging          21.3
Pillow             9.1.0
pip                22.0.4
pyparsing          3.0.8
PyQt5              5.15.6
PyQt5-Qt5          5.15.2
PyQt5-sip          12.10.1
PySide6            6.3.0
PySide6-Addons     6.3.0
PySide6-Essentials 6.3.0
PyWavelets         1.3.0
scikit-image       0.19.2
scikit-learn       1.0.2
scipy              1.8.0
setuptools         58.1.0
shiboken6          6.3.0
threadpoolctl      3.1.0
tifffile           2022.4.28

这是我与此错误相关的代码:

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QWidget,QInputDialog,QFileDialog
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtWidgets import *
from PyQt5.QtCore    import *
from PyQt5.QtGui     import *

self.actionOpen_Source.setShortcutVisibleInContextMenu(True)

这是错误信息:

File "T:\OOP-2 Lab Final\oop2labfinal.py", line 393, in setupUi
    self.actionOpen_Source.setShortcutVisibleInContextMenu(True)

AttributeError: 'QAction' object has no attribute 'setShortcutVisibleInContextMenu'

我解决了这个问题,尽管我没有完全理解它。我在下载 anaconda 之前下载了 spyder。我把Spyder删了,用anaconda下载,问题解决