close

[Solved] Python: Pandas read_excel cannot open .xls file, xlrd not supported

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Python: Pandas read_excel cannot open .xls file, xlrd not supported in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Python: Pandas read_excel cannot open .xls file, xlrd not supported Error Occurs?

Today I get the following error Python: Pandas read_excel cannot open .xls file, xlrd not supported in Python.

How To Solve Python: Pandas read_excel cannot open .xls file, xlrd not supported Error ?

  1. How To Solve Python: Pandas read_excel cannot open .xls file, xlrd not supported Error ?

    To Solve Python: Pandas read_excel cannot open .xls file, xlrd not supported Error make sure you are on a recent version of pandas, at least 1.0.1, and preferably the latest release.
    install openpyxl: https://openpyxl.readthedocs.io/en/stable/
    change your pandas code to be:pandas.read_excel('cat.xlsx', engine='openpyxl')

Solution 1

As noted in the release email, linked to from the release tweet and noted in large orange warning that appears on the front page of the documentation, and less orange but still present in the readme on the repo and the release on pypi:

xlrd has explicitly removed support for anything other than xls files.

This is due to potential security vulnerabilities relating to the use of xlrd version 1.2 or earlier for reading .xlsx files.

In your case, the solution is to:

  • make sure you are on a recent version of pandas, at least 1.0.1, and preferably the latest release.
  • install openpyxl: https://openpyxl.readthedocs.io/en/stable/
  • change your pandas code to be:pandas.read_excel('cat.xlsx', engine='openpyxl')

Edit: Currently, pandas >= 1.2 addresses this issue. (Release Notes)

Solution 2

The latest version of xlrd (2.0.1) only supports .xls files.

If you are prepared to risk potential security vulnerabilities, and risk incorrect parsing of certain files, this error can be solved by installing an older version of xlrd.

Use the command below in a shell or cmd prompt:

pip install xlrd==1.2.0

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment