Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support

前端 未结 15 2105
太阳男子
太阳男子 2021-02-01 12:04

I am trying to read a .xlsx with pandas, but get the follwing error:

data = pd.read_excel(low_memory=False, io=\"DataAnalysis1/temp1.xlsx\").fillna(         


        
相关标签:
15条回答
  • 2021-02-01 12:29

    This happened to me after I ran a script with cProfile a la python3 -m cProfile script.py even though xlrd was already installed and had never thrown this error before. it persisted even under python3 script.py. (Granted, I agree this wasn't what happened to OP, given the obvious import error)

    However, for cases like mine, the following fixed the issue, despite being told "requirement already met" in every case.

    pip install --upgrade pandas
    pip install --upgrade xlrd
    

    Pretty confounding stuff; not sure if cProfile was the cause or just a coincidence

    The following should work, assuming your pip install operated on python2.

    python3 -m pip install xlrd
    
    0 讨论(0)
  • 2021-02-01 12:30

    Please make sure your python or python3 can see xlrd installation. I had a situation where python3.5 and python3.7 were installed in two different locations. While xlrd was installed with python3.5, I was using python3 (from python3.7 dir) to run my script and got the same error reported above. When I used the correct python (viz. python3.5 dir) to run my script, I was able to read the excel spread sheet without a problem.

    0 讨论(0)
  • 2021-02-01 12:33

    This works for me: For Python 3

    pip3 install xlrd --user

    For Python2

    pip install xlrd --user

    0 讨论(0)
提交回复
热议问题