Make PyQt5.sip available as sip at runtime#1267
Make PyQt5.sip available as sip at runtime#1267htgoebel merged 1 commit intopyinstaller:developfrom tjstum:reintegrate
Conversation
|
Hmm, I'm wondering why this did not occur earlier. And in hook-PyQt5.py there is a hidden import for |
|
I can report the "no module named sip" happened for me also, on Windows only, using the Python3 branch as of a week ago. I did not investigate the cause. I circumvented the problem by adding hidden-import=sip to the command line. |
|
This is indeed still happening. I installed PyInstaller at 6f84a5a, and I tried this example code: I built it with PyInstaller by just running If I apply this one commit (cherry-picked on top) and rebuild the exact same code, the exact same way, the test works correctly (I get a message box saying "Hello") This is on Windows 7 x64 with Python 2.7 (also 64 bit). PyQt5 is installed from the python-qt5 package version 0.1.8 (the current in PyPI) |
|
I'm hesitating merging this because it hacks sys.modules, which looks dangerous to me. What makes me wonder is:
But sip already is listed as hidden import in hook-PyQt5.py. And I just installed PyQt5-5.4.1-gpl-Py3.4-Qt5.4.1-x64.exe in a wine-machine. There is no module PyQT5.sip in C:\Python34\lib\site-packages. |
There was a problem hiding this comment.
We should first test if sip can be imported:
try:
import sip
except ImportError:
try:
... your code ... It would be even better if we'd verify the module name.
Exactly so, and also in every (I think?) other PyQt5 hook, which made it very curious indeed. |
|
The |
|
From the
It makes sense that -1 should not ever be used when building for python3. Although, I'm curious if this issue occurs on python2. But I don't think that's the real issue. A good question is why the folder |
|
So this is a modulegraph bug, then? I am happy to do the suggestion in #1267 (comment) (i.e. trying to see if sip is normally available and then patching sys.modules as a last resort). I do think, though, that there should be some workaround (unless there's some way to avoid the issue altogether). Based on what I have seen, I don't think this has anything to do with Python 2 vs Python 3. I first encountered this issue on Python 2.7, but it also sounds like people are encountering the same problem in Python 3. I could be mistaken, though. @htgoebel: would you like me to make the change you suggested and update my branch? |
Yes. (I would prefer, if this would be fixed in modulegraph, though.) |
|
Sorry for the delay here. I modified my commit as you suggested, and I updated it to the current base. |
Make PyQt5.sip available as sip at runtime
|
Thanks. |
This fixes an issue where, at least on Windows, trying to use a PyQt5 module results in an ImportError at runtime.
Without this patch, a module using python-qt5 exits with the following error:
When I looked at the built binary, it looks like the module is just getting named
PyQt5.sip. The python-qt5 package expects the namesip. This small patch is sufficient to fix the problem, but if you would prefer a different approach, please let me know.