-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: initial prompt for reading .xlsx files misleadingly refers to xlrd, not openpyxl #41942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @huonw, This is actually a duplicate of #28546, but this issue is cleaner so we should probably track it in this one. |
This is actually fixed on master where it will only say The only remaining question now is whether to backport this to 1.2.x but I don't think there's enough time. |
which PR fixed this? |
I think I fixed this in #38710(see #38710 (comment)). Its a tricky backport to do though.(The changes to support .xlsb file inference are considered as an enhancement and can't be backported) |
fair enough. so probably can close. |
Great, thanks! No need to backport from my perspective. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Example (empty) excel file: https://github.com/pandas-dev/pandas/files/6635871/foo.xlsx
Problem description
Running the code example emits an error message that could be very helpful:
However, as of version 2, the xlrd library only supports xls files, not xlsx (#38410). This instruction is thus misleading: running
pip install xlrd
and then rerunning the code still fails:The correct/final resolution is thus to run
pip install openpyxl
. It's a bit of papercut to go though several steps here, especially as I suspect xlsx files are more common than xls these days (at least, it's been ~15-20 years since .xlsx was released according to https://en.wikipedia.org/wiki/Office_Open_XML).Expected Output
It would be nice if the original error message made it clearer what was going on. For instance, options might be:
ImportError: Missing optional dependency 'openpyxl'. Install openpyxl for .xlsx Excel support. Use pip or conda to install openpyxl.
)ImportError: Missing optional dependency 'xlrd' (for xls) 'openpyxl' (for xlsx). Install the appropriate one of these for Excel support. Use pip or conda to install xlrd or openpyxl.
)xlrd>=1.0.0,<2.0.0
(I personally feel that 1 would be the nicest.)
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.8.7.final.0
python-bits : 64
OS : Darwin
OS-release : 20.2.0
Version : Darwin Kernel Version 20.2.0: Wed Dec 2 20:40:21 PST 2020; root:xnu-7195.60.75~1/RELEASE_ARM64_T8101
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_AU.UTF-8
LOCALE : en_AU.UTF-8
pandas : 1.2.4
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 49.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
After
pip install xlrd
, it reports: xlrd: 2.0.1.The text was updated successfully, but these errors were encountered: