Just downloading a binary release of PyQt 5 and installing it, fails as it detects the PyQt 4, which needs to be uninstalled first, but doing this kills Spyder. Bummer.
Downloading the source and building it (which is actually very straightforward, just follow the instructions in the readme - don't forget to do (n)make install and update the Python module name list (in Spyder)), does the trick. Now both PyQt releases are available.
But importing QtCore from PyQt 5 causes a runtime crash:
RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject classObviously PyQt 4 is imported, too. A quick
import sys
confirms that. The reason for that is that Spyder installs a special input hook, replacing the input hook of PyQt, which is said to cause problems with Spyder. Fortunately you can disable this hook under Tools > Preferences > Console > External modules. After a restart of the current console, you can now import QtCore and you can start developing your stuff.sys.modules.keys()
There is a slight annoying thing regarding the hook though: you now can not interactively work with your application in the console. The solution for that comes in the next post.
Update: read my follow up post for a simpler and better solution.
Keine Kommentare:
Kommentar veröffentlichen