-2

处理使用 pyexcel 读取和写入使用 py2exe 编译的 .xls 文件的项目。

编译并确认 pyexcel、pyexcel-io 和 pyexcel-xls 在 library.zip 文件夹中后,我收到此错误。

Traceback (most recent call last):

File "FundDatabase.pyo", line 391, in get_worksheet

File "pyexcel\core.pyo", line 118, in get_book

File "pyexcel\core.pyo", line 137, in _get_book

File "pyexcel\sources\file_source_input.pyo", line 52, in get_data

File "pyexcel_io\io.pyo", line 31, in get_data

File "pyexcel_io\io.pyo", line 118, in load_data_new

File "pyexcel_io\manager.pyo", line 94, in create_reader

File "pyexcel_io\manager.pyo", line 89, in _get_a_handler

IOError: No suitable library found for xls

这是我的项目库

4

1 回答 1

0

简答

您需要告诉 pyinstaller 关于 pyexcel-xls 的隐藏导入。

为了打包pyexcel-xls,您需要指定:

--hidden-import pyexcel_xls
--hidden-import pyexcel_xls.xlsr
--hidden-import pyexcel_xls.xlsw

参考:动态加载模块的机制,与pyinstaller/cx_freeze的执行冲突

长答案

从 0.5.0 版本开始,pyexcel 使用延迟加载,这给 pystaller 带来了问题,因为并非所有模块都在程序启动时加载。因此,您需要告诉 pyinstaller 缺少的导入(也称为隐藏导入)。

Pyinstaller 注释

http://pyexcel.readthedocs.io/en/latest/pyinstaller.html

http://pyexcel-io.readthedocs.io/en/latest/pyinstaller.html

于 2017-11-11T11:14:23.827 回答