背景:最近用python寫一個excel解析工具,然后打包成exe可執行文件的時候,遇到這樣的問題
1.在我自己編譯器運行是可以正常將上傳后的excel進行解析,但是在打包成exe后,就無法正常解析excel
問題排查:
1.切換不同的打包工具,pyinstaller,py2exe,nuitka
2.切換conda虛擬環境
解決方案:
與python環境,打包工具沒關系,需要在pandas實例對象讀取excel時,指定解析引擎,添加參數 engine=‘openpyxl’
# 讀取 Excel 文件df = pd.read_excel(file_path, engine='openpyxl')# 顯示文件基本信息df.info()