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.
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.
I share with you my experience on this !
to check:
pip list
or conda list
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With