2017-03-23 68 views
1

使用運行時,該項目工程:無法與pyinstaller一起使用pyexcel-xls。 python可執行文件不起作用。 Python版本3.4.4

Python filename.py 

但是當我創建一個使用它的可執行文件創建成功「pyinstaller

pyinstaller -F filename.py 

的可執行文件,但腳本的執行失敗並引發以下錯誤。

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) 

我怎樣才能避免這種錯誤,並創建一個功能.exe文件?

我的客戶端有windows環境。

我也試過py2exe,但它與我的機器中的Windows DLL有一些衝突。

回答

3

的問題

pyexcel-io用來包括pyinstaller不支持的插件的方法。看到這個issue

的解決方法

此問題的解決辦法有幾個方面的。

變化需要pyexcel

我已經提交了Change Request它展示瞭如何修改pyexcel,使其能夠與pyinstaller工作。基本上pyexcel-io需要知道如何找到冷凍模塊。

如果pyexcel傢伙拿起變更請求,那會讓你去。但是,如果他們不這樣做,或者您很着急,那麼將the changed file從更改請求複製到您的網站包目錄中作爲pyexcel_io/__init__.py將使pyexcel正常工作。

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

pyinstaller還需要知道包含所需的模塊。所以pyinstaller命令行中你也將需要做:

--hidden-import pyexcel_xls.xls 

更新:此修復程序

更改請求已pyexcel的merged into master branch

更新#2:

修復已經releasedpypi

+0

調整「pyexcel_io/__ init__.py」的工作 –

0

我使用py2exe代替pyinstaller時遇到過同樣的問題。 在對我的代碼和一些Google搜索進行了一些研究之後,我最終在這個線程中發現問題類似,解決方案也是如此。 如果這可以幫助其他人,爲了使用生成可執行文件並使用pyexcel庫,我在py2exe安裝選項中包含包含'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'] 
)