1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Python / pandas] pd.read_excel で xls ファイルが開けないときのエラーとその対策

Posted at

症状: エラーパターン

見かけるエラーは3種類あります。

通常時 (2種類ありうる)

pd.read_excel() 実行時に以下の2つのエラーが発生することがあります。

ModuleNotFoundError: No module named 'xlrd'

ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 2.0.1 for xls Excel support Use pip or conda to install xlrd.

engine 指定時

read_excel()engine を指定できるのですが、 pd.read_excel(engine="openpyxl") のようにしていると、異なるエラーが発生します。

OSError: File contains no valid workbook part

まぁ、どっちにしろダメってことです😇

解決策

解決策は、上記 ImportError のエラーメッセージにあるように、 xlrd をインストールすることです。

pip install xlrd==2.0.2

そして、 engine 指定はしない ようにしましょう。

すると、 xls も読み込めるようになります( *¯ ꒳¯*)✨

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?