Setting up IPython Qtconsole with PyQt5

烈酒焚心 提交于 2019-12-01 04:11:26

The problem might be related to your python path.

I had almost the exact same problem. I had installed PyQt using Homebrew and I was getting the same error message. Finally what solved the problem was adding the following line to my .bash_profile:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

Since I am a beginner myself, I can't help you any further but I hope this solves the problem.

dermen

I know this is really old, but I was recently having trouble setting up PyQt5.

The problem was that PyQt5 would install, but some of the sub modules would not. For instance try

import PyQt5 #works
from PyQt5 import * # might fail

If the second command fails, then you have a problem with the PyQt5 setup, and you need to focus on that.

Specifically, ipython+qt will try to import the following

from PyQt5 import QtCore, QtSvg, QtWidgets, QtGui

If any of these sub-modules are broken/missing the qt console launch will quietly fail.

For me it turned out that the PyQt5 installer was failing to make the QtSvg bindings, which ipython tries to load from PyQt5. When you run the configure.py, use the -w option and you will see all the details of the build, allowing you to pinpoint where the install is failing.

In my case, a little googling and I found out that I was missing the QtSvg lib, which can be pulled in easily from the repos.

Setting environment variable QT_API=pyqt5 solved the same problem for me.

I had the same problem, though with the most recent brew of ipython the ImportError included PyQt5 (along with PyQt4 and PySide). So if it didn't work with PyQt5 before, it does now.

Adding the correct PYTHONPATH to .bash_profile fixed it for me, even in my virtualenv. (I don't have the reputation to up-vote or comment on oxtay's answer, where this would be more appropriate...)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!