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

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

    Since December 2020 xlrd no longer supports xlsx-Files as explained in the official changelog. You can use openpyxl instead:

    pip install openpyxl
    

    And in your python-file:

    import pandas as pd
    pd.read_excel('path/to/file.xlsx', engine='openpyxl')
    
    0 讨论(0)
  • 2021-02-01 12:12

    First of all you need to install xlrd & pandas packages. Then try below code.

    import xlrd
    import pandas as pd
    
    xl = pd.ExcelFile("fileName.xlsx")
    print(xl.parse(xl.sheet_names[0]))
    
    0 讨论(0)
  • 2021-02-01 12:13

    I had the same problem and none of the above answers worked. If you go into the settings (CTRL + ALT + s) and search for project interpreter you will see all of the installed packages. Click the + button at the top right and search for xlrd, then click install package at the bottom left.

    I had already done the "pip install xlrd" command from the file location of my python.exe before this, so you may need to do that as well. (you can find the file location by searching it in windows search bar and right click -> open file location, then type cmd into the file explorer address bar)

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

    Either use:

    pip install xlrd
    

    And if you are using conda, use

    conda install -c anaconda xlrd
    

    That's it. good luck.

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

    As @COLDSPEED so eloquently pointed out the error explicitly tells you to install xlrd.

    pip install xlrd
    

    And you will be good to go.

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

    You need to install the "xlrd" lib

    For Linux (Ubuntu and Derivates):

    Installing via pip: python -m pip install --user xlrd

    Install system-wide via a Linux package manager: *sudo apt-get install python-xlrd

    Windows:

    Installing via pip: *pip install xlrd

    Download the files: https://pypi.org/project/xlrd/

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