Python Forum

Full Version: Anaconda 5.1 Python can't see PYQT5
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I'm trying to write my first Python GUI application and have installed Anaconda 5.1 (Mac OSX) which includes PYQT5 and Python 3.6.

I'm also using the included VS Code as an IDE

I'm trying to use the above import statements from the beginning of a tutorial I ‘m following.


import sys
from PyQt5.QtWidgets import QApplication, QWidget
but I'm getting an error stating
E0611:No name 'QApplication' in module 'PyQt5.QtWidgets'
E0611:No name 'QWidget' in module 'PyQt5.QtWidgets'

It looks like PYQT5 needs additional configuration to get working as I assume the errors relate to the complier not locating PYQT5. Does anyone know what I can do to clear these errors?

Thanks in advance
Do you get this error from:
  • launch anaconda prompt
  • run:
    python
  • from PyQt5.QtWidgets import QApplication, QWidget
??
Hi Larz60+

Just tried your suggestion and it worked fine, no errors running the commands within Terminal.
Does that mean its likely a VS Code setup issue?

Thanks for the help

Pete



(May-05-2018, 12:25 PM)Larz60+ Wrote: [ -> ]Do you get this error from:
  • launch anaconda prompt
  • run:
    python
  • from PyQt5.QtWidgets import QApplication, QWidget
??
I can't be sure, I run vs code, but only once in a while for working on markdown.
How do you launch VS Code?
Hi

It seems to be working now??, I started trying multiple versions on Python through VSCode and have returned to "Anaconda, Inc. Python 3.6.4 (base)" and the GUI example is loading now. I'm still seeing the errors though.

If it isn't too much trouble, would you mind trying the following code in your version of VSCode to see if you see the same?

import sys
from PyQt5.QtWidgets import QApplication, QWidget

if __name__ == '__main__':
    
    app = QApplication(sys.argv)

    w = QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()
    
    sys.exit(app.exec_())
Below is what I see

[Image: 10z5pfs.png]

Thanks

Pete
It complain about the same for me in Pylint.
Open Command Palette and type pylint
Set enable to off,Pylint check for a lot of stuff that's is not errors(Traceback).
It's way to noise to have on all the time,
i only turn it on when i have code that want to check for all kind stuff like Coding Standard PEP-8 ect.
Thanks snippsat

I just turned it off, I'm only working on a personal project so not too worried about the coding standards.

Cheers for the help guys