If the PyInstaller development version is not needed for any reason, there is some fix.
An instance of BuiltinImporter , FrozenImporter and CExtensionImporter from PyInstaller.loader.pyi_importers added to sys.meta_path . And find_module method is called in order until one of them succeeds when the module is imported.
CExtensionImporter selects only one of the many suffixes for the C extension to load, i.e. wx._core_.i386-linux-gnu.so . Therefore, you cannot load the C extension wx._core_.so .
Buggy code;
class CExtensionImporter(object): def __init__(self):
Fix
1. Runtime hooks
You can fix the problem without changing the code using runtime hooks. This is a quick fix that fixes WxPython issues.
This runtime hook changes some of the private attributes of the CExtensionImporter instance. To use this hook, give --runtime-hook=wx-run-hook.py pyinstaller .
wx-run-hook.py
import sys import imp sys.meta_path[-1]._c_ext_tuple = imp.get_suffixes()[1] sys.meta_path[-1]._suffix = sys.meta_path[-1]._c_ext_tuple[0]
This second run-time bit completely replaces the object in sys.meta_path[-1] . Therefore, it should work in most situations. Use as pyinstaller --runtime-hook=pyinstaller-run-hook.py application.py .
pyinstaller-run-hook.py
import sys import imp from PyInstaller.loader import pyi_os_path class CExtensionImporter(object): """ PEP-302 hook for sys.meta_path to load Python C extension modules. C extension modules are present on the sys.prefix as filenames: full.module.name.pyd full.module.name.so """ def __init__(self):
2. Change code
class CExtensionImporter(object): def __init__(self):
Since imp.get_suffixes returns more than one suffix for type imp.C_EXTENSION , and the right one cannot be known in advance until a module is found, I will save them all in the list self._c_ext_tuples . The correct suffix is set to self._suffix , which is used with the self._c_ext_tuple method by the self._c_ext_tuple method, from the find_module method, if the module is found.
def find_module(self, fullname, path=None): imp.acquire_lock() module_loader = None
Nizam mohamed
source share