I'm using the Pandas read_excel function to import data from a spreadsheet. This works fine when run under the Python interpreter, but when I build an exe with PyInstaller it returns an IndexError.
Here's a simplified code pandas_test.py that demonstrates the problem:
import pandas as pd
filepath = 'C:/Users/User/Documents/Development/Python/PHL/Test Data/Study
template mock-up.xlsx'
df = pd.read_excel(filepath, sheet_name='Data Entry', index_col=9)
print(df.head())
This runs just fine under Python 3.6 with pandas 0.23.4 and xlrd 1.1.0.
When I build pandas_test.py with PyInstaller it successfully produces an pandas_test.exe, but I get this error:
Traceback (most recent call last): File "pandas_test.py", line 4, in <module> File "site-packages\pandas\io\excel.py", line 212, in read_excel File "site-packages\pandas\io\excel.py", line 513, in _parse_excel File "site-packages\pandas\io\parsers.py", line 1912, in TextParser File "site-packages\pandas\io\parsers.py", line 764, in __init__ File "site-packages\pandas\io\parsers.py", line 995, in _make_engine File "site-packages\pandas\io\parsers.py", line 2021, in __init__ File "site-packages\pandas\io\parsers.py", line 2772, in _get_index_name File "site-packages\pandas\io\parsers.py", line 3084, in _clean_index_names IndexError: list index out of range [17264] Failed to execute script pandas_test
I've read through the PyInstaller output, but there's nothing obviously related:
887 INFO: PyInstaller: 3.3.1
887 INFO: Python: 3.6.2
889 INFO: Platform: Windows-10-10.0.17134-SP0
892 INFO: wrote C:\Users\User\Documents\Development\Python\PandaTest\pandas_test.spec
I could understand if some module was not found, but why an IndexError only in the deployed code?