[Python] Python in Excel FileNotFoundError: [Errno 2] No such file or directory

Discussão em 'Python' iniciado por Stack, Maio 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have book1.xlsx and online_retail.xlsx in the same folder. Tried to load the Excel file into DataFrame using Pandas however it returned an error FileNotFoundError: [Errno 2] No such file or directory: 'online_retail.xlsx'.

    How to set Python in Excel current folder?


    Tried

    import pandas as pd
    df = pd.read_excel('online_retail.xlsx')


    Got

    FileNotFoundError: [Errno 2] No such file or directory: 'online_retail.xlsx'



    Tried

    import pandas as pd
    df = pd.read_excel(r'C:\Dev\Python\online_retail.xlsx')


    Got

    FileNotFoundError: [Errno 2] No such file or directory: '"C:\\Dev\\Python\\online_retail.xlsx"'



    Tried

    import os
    current_working_directory = os.getcwd()
    print(current_working_directory)


    Got

    /app



    Tried

    import os
    os.chdir("C:\Dev\Python")


    Got

    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Dev\\Python'
    <br>

    Continue reading...

Compartilhe esta Página