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

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

    I encountered a similar issue trying to use xlrd in jupyter notebook. I notice you are using a virtual environment and that was the key to my issue as well. I had xlrd installed in my venv, but I had not properly installed a kernel for that virtual environment in my notebook.

    To get it to work, I created my virtual environment and activated it.

    Then... pip install ipykernel

    And then... ipython kernel install --user --name=myproject

    Finally, start jupyter notebooks and when you create a new notebook, select the name you created (in this example, 'myproject')

    Hope that helps.

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

    I was getting an error

    "ImportError: Install xlrd >= 1.0.0 for Excel support"

    on Pycharm for below code

    import pandas as pd
    df2 = pd.read_excel("data.xlsx")
    print(df2.head(3))
    print(df2.tail(3))
    

    Solution : pip install xlrd

    It resolved error after using this. Also no need to use "import xlrd"

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

    I don't know if this will be helpful for someone, but I had the same problem. I wrote pip install xlrd in the anaconda prompt while in the specific environment and it said it was installed, but when I looked at the installed packages it wasn't there. What solved the problem was "moving" (I don't know the terminology for it) into the Scripts folder of the specific environment and do the pip install xlrd there. Hope this is useful for someone :D

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

    Was getting the error while I was using jupyter.

    ModuleNotFoundError: No module named 'xlrd'
    ...
    ImportError: Install xlrd >= 0.9.0 for Excel support
    

    it was resolved for me after using.

    !pip install xlrd
    
    0 讨论(0)
  • 2021-02-01 12:26

    I encountered same problem and took 2 hours to figure it out.

    1. pip install xlrd (latest)
    2. pip install pandas (latest)
    3. Go to C:\Python27\Lib\site-packages and check for xlrd folder (if there are 2 of them) delete the old version
    4. open a new terminal and use pandas to read excel. It should work.
    0 讨论(0)
  • 2021-02-01 12:26

    Another possibility, is the machine has an older version of xlrd installed separately, and it's not in the "..:\Python27\Scripts.." folder.

    In another word, there are 2 different versions of xlrd in the machine.

    when you check the version below, it reads the one not in the "..:\Python27\Scripts.." folder, no matter how updated you done with pip.

    print xlrd.__version__
    

    Delete the whole redundant sub-folder, and it works. (in addition to xlrd, I had another library encountered the same)

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