用pyinstaller创建的exe文件不能像.py文件一样正常工作(Pyexcel问题)

3
这是我的第一个问题 我在我的python(3.7.4)脚本中使用了pyexcel,并且它运行得很好。 然而,在使用Pyinstaller创建exe文件之后,我的exe文件无法运行,因为它不是.py文件。
以下是程序运行时出现的错误: (当我运行.py脚本时,这些问题没有出现)
  File "site-packages\pyexcel\core.py", line 110, in save_book_as

  File "site-packages\pyexcel\internal\core.py", line 39, in get_book_stream

  File "site-packages\pyexcel\plugins\sources\file_input.py", line 39, in get_data

  File "site-packages\pyexcel\plugins\parsers\excel.py", line 19, in parse_file

  File "site-packages\pyexcel\plugins\parsers\excel.py", line 40, in _parse_any

  File "site-packages\pyexcel_io\io.py", line 73, in get_data

  File "site-packages\pyexcel_io\io.py", line 91, in _get_data

  File "site-packages\pyexcel_io\io.py", line 190, in load_data

  File "site-packages\pyexcel_io\plugins.py", line 90, in get_a_plugin

  File "site-packages\lml\plugin.py", line 290, in load_me_now

  File "site-packages\pyexcel_io\plugins.py", line 107, in raise_exception

pyexcel_io.exceptions.SupportingPluginAvailableButNotInstalled: Please install pyexcel-xls

我已经完成了所有隐藏的导入,按照https://pyexcel-io.readthedocs.io/en/latest/pyinstaller.htmlhttps://pyexcel.readthedocs.io/en/latest/pyinstaller.html的说明。

这是我通过命令提示符使用的隐藏导入脚本。

--hidden-import pyexcel.plugins.renderers.sqlalchemy --hidden-import pyexcel.plugins.renderers.django --hidden-import pyexcel.plugins.renderers.excel --hidden-import pyexcel.plugins.renderers._texttable --hidden-import pyexcel.plugins.parsers.excel --hidden-import pyexcel.plugins.parsers.sqlalchemy --hidden-import pyexcel.plugins.sources.http --hidden-import pyexcel.plugins.sources.file_input --hidden-import pyexcel.plugins.sources.memory_input --hidden-import pyexcel.plugins.sources.file_output --hidden-import pyexcel.plugins.sources.output_to_memory --hidden-import pyexcel.plugins.sources.pydata.bookdict --hidden-import pyexcel.plugins.sources.pydata.dictsource --hidden-import pyexcel.plugins.sources.pydata.arraysource --hidden-import pyexcel.plugins.sources.pydata.records --hidden-import pyexcel.plugins.sources.django --hidden-import pyexcel.plugins.sources.sqlalchemy --hidden-import pyexcel.plugins.sources.querysets --hidden-import pyexcel_io.readers.csvr --hidden-import pyexcel_io.readers.csvz --hidden-import pyexcel_io.readers.tsv --hidden-import pyexcel_io.readers.tsvz --hidden-import pyexcel_io.writers.csvw --hidden-import pyexcel_io.readers.csvz --hidden-import pyexcel_io.readers.tsv --hidden-import pyexcel_io.readers.tsvz --hidden-import pyexcel_io.database.importers.django --hidden-import pyexcel_io.database.importers.sqlalchemy --hidden-import pyexcel_io.database.exporters.django --hidden-import pyexcel_io.database.exporters.sqlalchemy --hidden-import pyexcel_xls --hidden-import pyexcel_xls.xls --hidden-import pyexcel_xls.xlsr --hidden-import pyexcel_xls.xlsw

同时我已安装了以下内容。

pyexcel==0.5.15

pyexcel-io==0.5.20

**pyexcel-xls==0.5.8**

pyexcel-xlsx==0.5.8

PyInstaller==4.0.dev0+55c8855d9d

感谢每一个评论和答案!

附注:我已经安装了pyexcel-xls==0.5.8并添加了--hidden-import pyexcel_xls.xls

更新:exe文件仍然存在相同的问题。我应该发布Pyinstaller日志或我的Python脚本中导入的一些库吗?


尝试导入 pyexcel.ext.xlsxpyexcel.ext.xls - I_Al-thamary
我在我的脚本中添加了它,然后再次将其制作成exe文件,脚本运行良好,但exe仍然产生相同的结果。 - k54126
1个回答

0

首先,请确保您按照这些说明下载所有文件

然后,您必须在其隐藏的导入选项中指定插件

 pyinstaller run.py   --hidden-import pyexcel_xls --hidden-import pyexcel_xls.xls   --hidden-import pyexcel_xlsx --hidden-import pyexcel_xlsx.xlsx

#note 确保使用隐藏的导入选项来安装你需要的版本,并可以从“Read the Docs”选项卡中选择。

查看此处这个答案

如果你在PyInstaller中发现了一个bug,可以尝试下载最新版本

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

1
是的,我正在使用那个Pyinstaller压缩包,试图弄清楚问题是来自安装程序还是我的导入方法,我会尽快更新结果。非常感谢。 - k54126
我运行了代码,它在Python 3.7中可以正常工作。你使用的是哪个Python版本? - I_Al-thamary
我的版本是3.7.4,我的主要脚本大部分使用openpyxl和wx用于读取数据库并进行计算,我只是使用pyexcel将文件类型从xls转换为xlsx,以便openpyxl可以操作xlsx文件,但不幸的是,在exe程序中出现了错误。 - k54126
我注意到您使用了旧版本的 pyinstaller,并且对于最新版本的选项使用了隐藏导入。您需要安装最新版本并使用此链接:http://io.pyexcel.org/en/v0.5.11/pyinstaller.html - I_Al-thamary
请按照此指示操作 https://infotechmanagefactory.com/convert-xls-xlsx-python/ - I_Al-thamary

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接