我正在尝试使用以下命令使用pyinstaller将python文件转换为.exe。请说明这种方法有什么问题。
pyinstaller.exe --hidden-import pyexcel --hidden-import pyexcel-io --hidden-import pyexcel_xls --hidden-import pyexcel_xlsx -F FormatBuster.py
该项目还有额外的pyexcel_xls导入,pyexcel_xlsx正在使用--hidden-import参数进行处理。运行.exe时出现以下错误,但是直接执行.py文件时,它运行正常。
Traceback (most recent call last):
File "FormatBuster.py", line 90, in <module>
File "site-packages\pyexcel\core.py", line 36, in get_sheet
File "site-packages\pyexcel\internal\core.py", line 19, in get_sheet_stream
File "site-packages\pyexcel\internal\source_plugin.py", line 76, in get_source
File "site-packages\pyexcel\internal\source_plugin.py", line 65, in get_a_plugin
File "site-packages\pyexcel\internal\source_plugin.py", line 48, in load_me_now
File "site-packages\pyexcel\internal\source_plugin.py", line 138, in _error_handler
pyexcel.exceptions.UnknownParameters: Please check if there were typos in function parameters: {'file_name': 'C:\\Users\\kiranv1\\Documents\\R&D\\FormatBuster\\input\\DDVIJAYA_13_Apr_2018_Lot_1.xls'}. Otherwise unrecognized parameters were given.
[146004] Failed to execute script FormatBuster
python文件使用.config文件,其内容如下所示
{
"params":{
"inputpath":"C:\\Users\\kiranv1\\Documents\\R&D\\FormatBuster\\input",
"outputpath":"C:\\Users\\kiranv1\\Documents\\R&D\\FormatBuster\\output",
"logpath":"C:\\Users\\kiranv1\\Documents\\R&D\\FormatBuster\\output",
"files": {
"DDVIJAYA" : {
"Due Date":"T2D",
"Instalment No.":"T2N",
"Instalment Amount":"T2N"
}
}
}
}
答案 0 :(得分:0)
在问题得到解决后添加答案。由于缺少PyExcel的依赖项模块而发生错误。以下github页面列出了打包所需的所有依赖项。 PyExcel Dependency List for packaging
更新的pyinstaller代码如下所示
pyinstaller --noconfirm --log-level=DEBUG ^
--onefile ^
--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_xlsx
--hidden-import pyexcel_xlsx.xlsxr
--hidden-import pyexcel_xlsx.xlsxw
--hidden-import pyexcel_xlsxw
--hidden-import pyexcel_xlsxw.xlsxw
--hidden-import pyexcel_xls
--hidden-import pyexcel_xls.xlsr
--hidden-import pyexcel_xls.xlsw
FormatBuster.py