PyCharm中没有PyQt4的自动完成功能

时间:2021-08-21 21:20:03

On my office PC I'm using

在我的办公室电脑上,我正在使用

  • Python 3.4
  • Python 3.4
  • PyQt4 Version 4.11.1
  • PyQt4版本4.11.1
  • PyCharm Community Eddition 3.4.1
  • PyCharm社区编辑3.4.1

I installed everything in the order as stated above.

我按照上面说明的顺序安装了所有东西。

However, code completion does not work. It works for imports, but not for classes and methods.

但是,代码完成不起作用。它适用于导入,但不适用于类和方法。

I made a small sample program:

我制作了一个小样本程序:

import sys
from PyQt4 import QtGui


app = QtGui.QApplication(sys.argv)

window = QtGui.QWidget()

window.setWindowTitle("Test")
window.resize(300, 200)
window.show()

sys.exit(app.exec_())

In the code above none of the classes or methods were suggested by PyCharm.

在上面的代码中,PyCharm没有提出任何类或方法。

If I type window.setW I would expect it to suggest setWindowTitle() but it doesn't.

如果我输入window.setW我会期望它建议setWindowTitle()但它没有。

Strange thing is, that I'm using the same setup on my computer at home and there it works like a (Py)charm... Autocompletion, auto imports, etc. As far as I remember I installed it the same way as I did on my office PC.

奇怪的是,我在家里的电脑上使用相同的设置,它就像一个(Py)魅力...自动完成,自动导入等等。据我记得我安装它的方式和我一样在我的办公室电脑上做了。

I already looked at some similiar questions but this question has no answers and others don't contain relevant information that helped me so far.

我已经查看了一些类似的问题,但这个问题没有答案,而其他问题没有包含迄今为止帮助我的相关信息。


Don't know if it is relevant but at this line

不知道它是否相关但是在这条线上

from PyQt4 import QtGui

PyCharm tells me

PyCharm告诉我

Unresolved reference 'QtGui'

未解决的参考'QtGui'

Maybe the reason for this is the same.

也许这个原因是一样的。

3 个解决方案

#1


12  

I had the same problem on Linux, pyqt5 and pycharm CE. The solution was to rebuild the skeletons with: File > Invalidate Caches / Restart > Invalidate and Restart.

我在Linux,pyqt5和pycharm CE上遇到了同样的问题。解决方案是使用以下方法重建框架:文件>使高速缓存/重新启动无效>无效并重新启动。

#2


1  

The problem was solved by installing PyCharm first and then Python and PyQt.

首先安装PyCharm然后再安装Python和PyQt解决了这个问题。

Afterwards I had to configure the interpreter in PyCharm and it worked.

之后我不得不在PyCharm中配置解释器并且它有效。

When I posted the question I installed Python, then PyQt and then PyCharm.

当我发布问题时,我安装了Python,然后是PyQt,然后是PyCharm。

Oddly enough, it worked in this order on another PC.

奇怪的是,它在另一台PC上按此顺序工作。

#3


0  

I went through the same issue recently. Unfortunately, the install order didn't solve it for me.

我最近经历了同样的问题。不幸的是,安装顺序并没有为我解决。

There is a bug report here. Downloading the Early Access Program release worked and can be found here

这里有一个错误报告。下载Early Access Program发布版本可以在此处找到

#1


12  

I had the same problem on Linux, pyqt5 and pycharm CE. The solution was to rebuild the skeletons with: File > Invalidate Caches / Restart > Invalidate and Restart.

我在Linux,pyqt5和pycharm CE上遇到了同样的问题。解决方案是使用以下方法重建框架:文件>使高速缓存/重新启动无效>无效并重新启动。

#2


1  

The problem was solved by installing PyCharm first and then Python and PyQt.

首先安装PyCharm然后再安装Python和PyQt解决了这个问题。

Afterwards I had to configure the interpreter in PyCharm and it worked.

之后我不得不在PyCharm中配置解释器并且它有效。

When I posted the question I installed Python, then PyQt and then PyCharm.

当我发布问题时,我安装了Python,然后是PyQt,然后是PyCharm。

Oddly enough, it worked in this order on another PC.

奇怪的是,它在另一台PC上按此顺序工作。

#3


0  

I went through the same issue recently. Unfortunately, the install order didn't solve it for me.

我最近经历了同样的问题。不幸的是,安装顺序并没有为我解决。

There is a bug report here. Downloading the Early Access Program release worked and can be found here

这里有一个错误报告。下载Early Access Program发布版本可以在此处找到