0

PyCharm 2017.3 Community Edition, Windows 7 64, Anaconda 64-bit

I've created a virtual environment in Anaconda for Python 3.5.4. In Pycharm Settings > Project > Project Interpreter is set to this virtual environment. Using the + button on the Project Interpreter page I've installed PyQt5.

enter image description here

When I import anything from PyQt5, PyCharm complains about unresolved references and autocomplete does not work for PyQt5 methods/classes.

enter image description here

I installed qtpy module and I faced the same problem with some methods.

enter image description here

I tried import PyQt5and it doesn't complain about unresolved references, but I don't get autocomplete. The script runs fine though.

PyCharm can't resolve references to PyQT5 modules seems to provide a solution, but I'm not sure how to install a module within PyCharm.

PS: I understand that this might be a duplicate of some existing question but none of the suggested solutions have worked for me.

kronosjt
  • 703
  • 4
  • 10
  • 24

2 Answers2

0

For some reason the Python version in the virtual environment that I was using for this project was 2.7.4, even though I had created a virenv for Python 3.5.4. So I updated Python for this environment to 3.5.4 and unresolved references errors went away and autocomplete works correctly.

enter image description here

kronosjt
  • 703
  • 4
  • 10
  • 24
0

Hope this my one stop answer saved your day

possible duplicate:

6 years, 9 months ago

PyCharm shows unresolved references error for valid code

2 years, 11 months ago

PyQt5 and pycharm unresolve references?

1 year, 11 months ago

PyCharm can't resolve references to PyQT5 modules

This answer based my experience today:

I've tried many installation of PyQt5 from cmd and although all installation has successful but unresolved reference always happen:

Unresolved reference 'QApplication'

i've tried a lot, down grade and up grade versions of PyQt5 from cmd like:

-pip install PyQt5==5.10
-pip uninstall PyQt-sip==4.9.8
-pip install PyQt-sip==4.9.7
-pip install PyQt5-tools==4.9.0.1.2

The command line or cmd never give me a solution. One Solution is install a module within PyCharm. It works like a charm. This is the complete tutorial

https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

but i will repat it again here based my experiance:

First i cannot and always fail when installing PyQt5 within PyCharm. It's happen maybe because i use PyCharm Version 2017.3.3 so i upgrade the version to 2018.3.6 because 2019.3 not support 32bit, i use 32bit by the way.

Second i upgrade Python from 3.6.4 to 3.7.3

Last i installing PyQt5 within PyCharm.

File -> Settings -> Project:mypackage --> Project interpreter --> plus toggle

installing PyQt5 within PyCharm

installing PyQt5 within PyCharm

not like before, the installation of PyQt5 within PyCharm now Successful. But something happen, you know what? Unresolved reference QApplication or QtWidgets still happen. Oh maaaaan! I confuse, what wrong with my computer, i see from tutorial youtube PyQt5 installation run smoothly. Ok, i should looking the way, it should be easy. So i decided to Install All PyQt5 module which i checklist blue on the image below even upgrade all to the very very latest version:

upgrade all to the latest version

under my deadline,

Unresolved reference QApplication solved.

Unresolved reference QtWidgets solved

i have read how to solved this issue manually,

Error installing PyQt5 library: unresolved reference

but the step too long. And finally within PyCharm installation is the pretty simple solution. This final result, work like a charm:

Unresolved reference 'QtWidgets' solved

snow
  • 1
  • 1