New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling sip.setapi
does not work if app has already imported from PyQt4
#276
Comments
Unfortunately, there is not a good alternative. IPython is now using the v2 string API for both PySide and Python 3 compatibility reasons. This means that any Qt code using IPython must also use the v2 API. To avoid having to order your imports in a silly way, you should make a call to sip.setapi before any Qt imports in the main script of your application. (You do not, of course, need to put a setapi call anywhere else.) |
Any workarounds for projects where I don't have commit access to the main script? Or that contain significant amounts of Python code that use QString? |
As far as I know, you have to pick one version of the API per project. So if IPython stuck with the v1 API, it couldn't be integrated with projects using the v2 API. No solution springs to mind, unfortunately. For an idea of how much code is affected in IPython, see the diff at #259. |
I guess we'll need to close this one, since there isn't really anything we can do on our side. If anyone ever comes around with a better solution (doubtful) we can reopen and apply it. |
Take the following example for a minimal Qt shell:
Trying to run this fails with the following error:
Rearranging the imports in the following order allows it to succeed:
Apparently, in order for the
sip.setapi
to be valid, a PyQt application can't have made any PyQt4 imports before importing from the IPython interface. For a simple one-file script like this there is no problem. However, adding an IPython widget into a large project would be difficult.Is there any alternative to using
sip.setapi
?The text was updated successfully, but these errors were encountered: