Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pandas

I used pandas to read excel file and then received an ImportError shown below.

code:

pressure_2018=pd.read_excel('2018_pressures.xlsx')

Error:

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

Then I installed xlrd on my computer using code shown below:

pip install xlrd

But I still received the same issue. In output, it always returned this ImportError. It made me feel confused and frustrated, because I have installed xlrd on my computer. Could you please give me some ideas about how to resolve this error.

like image 632
czy Avatar asked Apr 28 '21 10:04

czy


Video Answer


3 Answers

You can install openpyxl using pip install openpyxl and then try:

pd.read_excel('2018_pressures.xlsx', engine='openpyxl')

This is an alternative solution but it will work.

like image 61
Hamza usman ghani Avatar answered Oct 16 '22 08:10

Hamza usman ghani


I share with you my experience on this !

  1. step check whether you have the following excel packages installed: openpyxl, odf, xlrd

to check: pip list or conda list

  1. If there is no installation package reading the excel file, then install one of them with this method:

    pip install xlrd, pip install openpyxl, pip install odf or pip install pyxslb

for conda : conda install xlrd, conda install openpyxl, conda install odf, conda install pyxslb then check again whether your file reads correctly:

dataFrame = pd. read_excel('C:/.../.xlsx', engine= 'openpyxl')

if it gives an error again, it means that you are using another interpreter to read the code if you want to read it in https://www.kaggle.com/abdumaleek/kasco-tasks/editkaggle or in collaboration, then you need to install the package for reading exel file again

for example, in kaggle : !pip install openpyxl

import openpyxl
df = pd. read_excel('C:/.../.xlsx', engine= 'openpyxl')

this is 100% should work support with a like

like image 3
Abdumaleek Avatar answered Oct 16 '22 09:10

Abdumaleek


I'm in Windows 10. I downloaded all of Anaconda on 1 computer and just the Spyder part on a different computer from Anaconda web site. The computer with all of Anaconda on it did not get this error; the computer with just Spyder on it got this error of not being able to find xlrd when doing the following

import pandas as pd

import urllib.request

urllib.request.urlretrieve("https:a internet file name in here that is an xlsx file", "sample.xlsx")

df = pd.read_excel("sample.xlsx")

df
like image 2
Pat b Avatar answered Oct 16 '22 08:10

Pat b