Skip to content
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

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

Closed
kerneltravel opened this issue Sep 21, 2017 · 4 comments

Comments

@kerneltravel
Copy link

kerneltravel commented Sep 21, 2017

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 ?

@chfw
Copy link
Member

chfw commented Sep 21, 2017

Does this note help?

@kerneltravel
Copy link
Author

@chfw the note works ! GREAT job&docs :p
thanks very much.

@chfw chfw closed this as completed Sep 21, 2017
@kerneltravel
Copy link
Author

kerneltravel commented Sep 21, 2017

the resulting project is opensourced xlsx2csv_gui, as an usage example.

@chfw
Copy link
Member

chfw commented Sep 21, 2017

Thanks for sharing. Your happiness with pyexcel is my pleasure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants