skip to Main Content

I want to read the data on an excel file within a F drive. I am using python on Visual Studio Code to try achieve this however I am getting an error as seen in the pictures below. I installed pandas but I still get an error. How can I fix this issue?

Coding Error

Installed Pandas Library

I tried closing and opening visual studio. I tried uninstalling and reinstalling pandas.

Python on Computer

2

Answers


  1. You should try to open terminal in VS Code, and run pip freeze (and pip3 freeze). Check if you find pandas in the results, it won’t. That must be because you’d have multiple installations of Python on your system. You may do any one of the below –

    1. Get rid of all but one Python installation.
    2. Install pandas on the VS Code installed python instance.
    3. Configure the same installation of python that is referenced by your command prompt. (choose the correct python interpreter from VS Code Command Palette)
    Login or Signup to reply.
  2. To read an Excel file with Python, you need to install the pandas library. To install pandas, open the command line or terminal and type:

    pip install pandas

    Once pandas is installed, you can read an Excel file like this:

    import pandas as pd

    df = pd.read_excel(‘file_name.xlsx’)

    print(df)

    You should also make sure that the file path is correct and that you have the correct permissions to access the file.
    If you are still having issues, try using the absolute file path instead of a relative file path.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search