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

前端 未结 15 2102
太阳男子
太阳男子 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
    

提交回复
热议问题