Hello, I have a PySide2 application that I need to reduce the startup time of. Nuitka seems to be well regarded as faster, and my hope is that compiled code would also have less startup overhead.
Does anyone here have experience using Nuitka with PySide2? The nuitka invocation here seems that it should be straightforward but I get the error ModuleNotFoundError: No module named 'PySide2' and I’m wondering if this has something to do with NixOS.
My shell.nix looks like this and I can run my application from a --pure invocation.
PS: I understand that a much simpler and faster solution is using C++ directly but Python saves me iteration time, so I’m specifically looking for solutions regarding Nuitka.
Adding ps.Nuitka and compiling in a pure shell (+nixpkgs.chrpath) removed the ModuleNotFoundError, thank you. I still can’t the compiled binary to run but I suspect the error is related to Nuitka and not NixOS. Marking this question solved but still posting the error.
Traceback (most recent call last):
File "/code/zx/workspace/projects/mono/samples/Qt/QtPy/jj/boiler.dist/boiler.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/code/zx/workspace/projects/mono/samples/Qt/QtPy/jj/boiler.dist/PySide2/__init__.py", line 51, in <module PySide2>
File "/code/zx/workspace/projects/mono/samples/Qt/QtPy/jj/boiler.dist/PySide2/__init__.py", line 23, in _setupQtDirectories
AttributeError: type object 'type' has no attribute '__signature__'
Notice the --standalone in second. I managed to get the 1st invocation working correctly in Arch (window shows fine). The same invocation gives
Traceback (most recent call last):
File "/code/zx/workspace/projects/mono/samples/Qt/QtPy/boiler.py", line 1, in <module>
from PySide2.QtWidgets import *
ModuleNotFoundError: No module named 'PySide2'
in a pure nix shell.
Again, in NixOS, I got a similar error earlier when I invoked (2), where @Fridh’s suggestion resolved that. For (2) arch gives me error as well.
That said, my startup didn’t improve (3 secs in both cases) so I have no need to pursue this further.