Skip to content

mechanism of dynamic load module, confilict with pyinstaller/cx_freeze's execution #19

@kerneltravel

Description

@kerneltravel

Hi, I‘ve test an pyqt GUI app with pyexcel_xlsx, my application is finally packaged as an exectuion file by pyinstaller OR cx_freeze,

pyinstaller.exe  --distpath dist_pyinstaller  -F mainc.py 

and get dist_pyinstaller\mainc.exe binary file.
the application can start well. but will fail when it's time to use pyexcel_xlsx functionility.

Traceback (most recent call last):
  File "pyexcel2csv_gui\winmain\winmain.py", line 72, in  on_btnSelectExcelFileAndExport2Csv_clicked
  File "site-packages\pyexcel_xlsx\__init__.py", line 38, in get_data
  File "site-packages\pyexcel_io\io.py", line 65, in get_data
  File "site-packages\pyexcel_io\io.py", line 83, in _get_data
  File "site-packages\pyexcel_io\io.py", line 173, in load_data
  File "site-packages\pyexcel_io\plugins.py", line 78, in get_a_plugin
  File "site-packages\lml\plugin.py", line 275, in load_me_now
  File "site-packages\lml\plugin.py", line 303, in dynamic_load_library
  File "site-packages\lml\utils.py", line 60, in do_import_class
ImportError: No module named xlsxr

anlyse the source code

def do_import_class(plugin_class):
    """dynamically import a class"""
    try:
        plugin_module_name = plugin_class.rsplit('.', 1)[0]
        #print plugin_module_name,   plugin_class 
        #shows "pyexcel_xlsx.xlsxr"    , shows  "pyexcel_xlsx.xlsxr.XLSXBook"
        plugin_module = __import__(plugin_module_name)
        modules = plugin_class.split('.')
        for module in modules[1:]:
            plugin_module = getattr(plugin_module, module)
        return plugin_module
    except ImportError:
        log.exception("Failed to import %s", plugin_module_name)
        raise

pyexcel_xlsx has been installed by pip. and

site-packages\pyexcel-xlsx\xlsxr.py

file exists.

if directory call by CLI way

python.exe  mainc.py

to run same mainc.py script, ALL works ok.
ENV is python 2.7.9.

so , seems the dynamic loading not works well in pyinstaller OR cx_freeze situation ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions