問題描述
我有:
- Python 2.7 (Anaconda x64),效果很好
- PyQt5(使用
pip install python-qt5
安裝) - PyCharm 4.04 Professional(最近從 3.4.1 升級)
- 一個小型
Qt
應用程序
- Python 2.7 (Anaconda x64), which works great
- PyQt5 (installed using
pip install python-qt5
) - PyCharm 4.04 Professional (recently upgraded from 3.4.1)
- A small
Qt
application
費盡心思(因為 Riverbank 沒有為 Python 2.7 提供 PyQt5 二進制文件,僅適用于3.3+) 多虧了 Marcus Otosson 的 預編譯的二進制包,我得到了一切工作.
After much hair-pulling (since Riverbank doesn't provide a PyQt5 binary for Python 2.7, only for 3.3+) I got everything working thanks to Marcus Otosson's pre-compiled binary packages.
Qt 現在已安裝并且功能齊全.我的 Qt
應用程序運行良好!
Qt is now installed and fully functional. My Qt
application runs great!
但應用程序尚未完成,并且 PyCharm 不會為 PyQt 模塊完成代碼完成.它甚至無法識別任何 PyQt5 子模塊(如 Qwidgets)的存在:即使它們工作得很好,我仍然會收到紅色波浪形 "Unresolved Reference"
警告.
But the application isn't finished yet, and PyCharm won't do code completion for the PyQt modules. It won't even recognize that any PyQt5 sub-modules (like Qwidgets) exist: even though they work just fine, I still get the red squiggly "Unresolved Reference"
warning.
我該如何解決這個問題?我認為這與為二進制 *.pyd
文件生成骨架的固有困難有關.它是如何工作的?我可以手動生成代碼骨架,還是從它們正確生成的地方導入它們?
How do I fix this? I assume this has to do with the inherent difficulties in generating skeletons for binary *.pyd
files. How does it work exactly? Can I manually generate code skeletons, or import them from somewhere they generated correctly?
卸載并重新安裝 PyCharm 沒有幫助.重新配置解釋器也沒有強制骨架生成器再次運行.
Uninstalling and re-installing PyCharm didn't help. Neither did re-configuring the interpreter to force the skeleton generator to run again.
在我禿頂之前請幫忙.
推薦答案
在 PyCharm 2017.1.1 中遇到了同樣的問題.不要這樣做
Had the same problem in PyCharm 2017.1.1. Don't do
import PyQt5.QtWidgets
做
from PyQt5 import QtWidgets
這篇關于Pycharm、PyQt5 和 Python 2.7——沒有代碼完成的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!