无法与pyinstaller一起使用pyexcel-xls。 python可执行文件不工作。 python版本3.4.4

该程序运行时使用:

Python filename.py 

但是当我使用“ pyinstaller ”创build它的可执行文件

 pyinstaller -F filename.py 

可执行文件已成功创build,但脚本的执行失败并引发以下错误。

 Traceback (most recent call last): File "site-packages\pyexcel_io\manager.py", line 160, in create_reader File "site-packages\pyexcel_io\manager.py", line 222, in _get_a_handler pyexcel_io.manager.NoSupportingPluginFound: No suitable library found for xls During handling of the above exception, another exception occurred: Traceback (most recent call last): File "script.py", line 8, in <module> File "site-packages\pyexcel_xls\__init__.py", line 29, in get_data File "site-packages\pyexcel_io\io.py", line 36, in get_data File "site-packages\pyexcel_io\io.py", line 126, in load_data File "site-packages\pyexcel_io\manager.py", line 171, in create_reader pyexcel_io.manager.SupportingPluginAvailableButNotInstalled: Please install pyexcel-xls Failed to execute script script 

相应的python脚本是:

 from pyexcel_xls import save_data , get_data data = get_data("registered-market-makers-by-security.xls") save_data("file_to_consume.xls", data) 

我怎样才能避免这个错误,并创build一个function的.exe文件?

我的客户有Windows环境。

我也试过py2exe,但它与我的机器中的Windows DLL有一些冲突。

问题

pyexcel-io使用一种方法来包含pyinstaller不支持的插件。 看到这个问题 。

解决方法

这个问题的解决方法有几个方面。

需要更改pyexcel

我已经提交了一个更改请求 ,显示如何修改pyexcel以允许它使用pyinstaller。 基本上pyexcel-io需要知道如何找到冻结的模块。

如果pyexcel家伙拿起变更请求,那么这会让你走。 但是,如果他们不这样做,或者你很着急,那么将更改后的文件从更改请求复制到您的站点软件包目录中,如pyexcel_io/__init__.py将使pyexcel正常工作。

但是,pyinstaller也需要知道要包含什么。

pyinstaller也需要知道包含所需的模块。 所以在pyinstaller命令行上,你也需要做:

 --hidden-import pyexcel_xls.xls 

更新:

使用此修复程序更改请求已合并到 pyexcel的主分支中。

更新#2:

Fix已经发布到pypi 。

我经历了py2exe代替pyinstaller相同的问题。 在对我的代码进行了一些研究之后,我搜索了一些内容,结果发现问题是相似的,解决方案也是如此。 如果这可以帮助其他人,为了使用pyexcel库生成py2exe可执行文件,我在py2exe安装选项的includes section中添加了'pyexcel_xls.xls''pyexcel_xlsx.xlsx' 。 所以:

 setup( name='Hello' version='0.1' description='Hello program' author='Me' options={ 'compressed': 1 'optimized': 1 'includes': ['pyexcel_xls.xls', 'pyexcel_xlsx.xlsx' ...] } console=['hello.py'] )