Search code examples
pythonpyqt5spyder

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


I am using Spyder on Windows.

These are my python version and modules:

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

This is my code related to this error:

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)

This is the error message:

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

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

Solution

  • I solved the problem even though I didn't fully understand it. I had downloaded spyder before downloading anaconda. I deleted Spyder and downloaded it from anaconda and the problem was solved.