Problem with uic module from PyQt5

Good Afternoon, 

While working with PyQt5, I have noticed that PyCharm signals an unresolved reference to 'uic' when I try to import it from PyQt5, although it is actually installed in the venv folder. 

from PyQt5 import uic  # Pycharm: 'Module not found' // Compiler: no problem.

As a matter of fact, if I ignore the warning and just run the code, it works flawlessly. 

Still, the quirk is annoying because it doesn't allow to use code completion and error marking features of PyCharm. For instance, if I try to call a component (QWidget) from a GUI in a UI file, the autocompletion won't work; example:

uic.loadUi('my_gui.ui', self)
self.searchResultsView.setColumnWidth(0, 250) # searchResultsView is an object in my_gui.ui

Is this a bug, does anybody experience this as well or am I doing something wrong? Is there a workaround?

I don't use Qt Designer much and I usually prefer making up my GUIs programmatically (one of the reasons is to avoid this kind of headaches...), but the idea of being able to 'encapsulate' many lines of code in an external file is appealing. 

2

Hello,

I've tried to reproduce the issue, but after compiling qt5, the import works as expected. 

Please try File | Invalidate caches.  Also, what version of Python are you using? 

1

I have the same problem, but File | Invalidate caches doesnt work

0

Timofijandrusenko  We would need additional details such as logs to understand the case better. Could you please create a new request at https://youtrack.jetbrains.com/newIssue?project=PY and attach the IDE UI logs from Help | Collect Logs and Diagnostic Data

0

请先登录再写评论。