0

我的 Python 3.5 代码如下所示:

folder_with_files = 'C:\\procXls\\20170809\\'
path_to_m = folder_with_files + names[0]
sheet_m = pe.get_sheet(file_name=path_to_m) #this is 72 line 

当我在 IDE 中执行程序时,一切正常。但是在使用pyinstaller并运行程序编译成 .exe 文件后,我收到了下一个堆栈跟踪:

C:\procXls>procXls.exe
2017-08-10 11:31:42,316 - root - INFO - Begin
['M_09082017.XLS', 'M_MVT_09082017.XLS', 'M_TRN_09082017.XLS', 'D_09082017.XLSX', 'I_09082017.XLSX']
Processing file C:\procXls\20170809\M_09082017.XLS
2017-08-10 11:31:42,317 - pyexcel.internal.source_plugin.SourcePluginManager - DEBUG - load me now:sheet-read
Traceback (most recent call last):
  File "procXls.py", line 72, 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:\\procXls\\20170809\\M_09082017.XLS'}. Otherwise unrecognized parameters were given.
Failed to execute script procXls

有谁知道如何解决这个异常?

更新

我改变了我的代码:

folder_with_files = os.path.join("c:\\", "procXls", "20170809\\") 
path_to_m = os.path.join(folder_with_files, names[0])

但回溯是相同的:

Process file: c:\procXls\20170809\M_09082017.XLS
2017-08-11 09:42:53,983 - pyexcel.internal.source_plugin.SourcePluginManager - DEBUG - load me now:sheet-read
Traceback (most recent call last):
  File "procXls.py", line 75, 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:\\procXls\\20170809\\M_09082017.XLS'}. Otherwise unrecognized parameters were given.
Failed to execute script procXls

更新 1

问题仍然没有解决。 pip list返回:

amqp (2.2.1)
asn1crypto (0.22.0)
bcrypt (3.1.3)
billiard (3.5.0.3)
celery (4.1.0)
cffi (1.10.0)
cryptography (2.0.3)
cx-Freeze (5.0.2)
ezodf (0.3.2)
Fabric (1.13.2)
fdb (1.7)
future (0.16.0)
idna (2.5)
kombu (4.1.0)
lml (0.0.1)
lxml (3.8.0)
numpy (1.13.1)
pandas (0.20.3)
paramiko (2.2.1)
pdfkit (0.6.1)
pip (9.0.1)
pyasn1 (0.3.2)
pycparser (2.18)
pyexcel (0.5.3)
pyexcel-io (0.4.3)
pyexcel-ods3 (0.4.0)
pyexcel-xls (0.4.0)
PyInstaller (3.2.1)
PyNaCl (1.1.2)
pypiwin32 (219)
pypyodbc (1.3.4)
python-dateutil (2.6.1)
pytz (2017.2)
PyYAML (3.12)
setuptools (18.2)
six (1.10.0)
texttable (0.9.1)
vine (1.1.4)
wkhtmltopdf (0.2)
xlrd (1.0.0)
xlwt (1.2.0)

对解决问题有帮助吗?

4

2 回答 2

1

如果它在IDE中运行而不是.exe,可能是您提供的路径格式以后不理解吗?我通常不喜欢使用“//”或一些变体来创建路径。尝试使用:

folder_with_files = os.path.join("c:", "procXls", "20170809")
path_to_m = os.path.join(folder_with_files, names[0])
sheet_m = pe.get_sheet(file_name=path_to_m)

看看情况如何:)

于 2017-08-10T09:17:46.980 回答
0

您需要告诉 pyinstaller隐藏的导入

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

类似的问题:

在 py2exe 中读取 xlsx 文件

人们尝试使用pyinstaller 并取得了成功

于 2017-10-05T20:08:07.113 回答