[Python] How to solve python error "does not exist" when using pd.read_csv() and absolute path?

Discussão em 'Python' iniciado por Stack, Abril 3, 2025.

  1. Stack

    Stack Membro Participativo

    I've been trying to import a csv file from my Desktop folder (Mac) but getting error message "File does not exist." Problem is I'm copying the full path name and can confirm the file in fact exists. Anyone able to point out what step I'm missing? (using Google colab notebook)

    CODE:
    pd.read_csv(filepath_or_buffer='/Users/ekselan/Desktop/NBA DFS/FantasyLabs_NBAProjections_3_7_2020.csv')

    ERROR:

    <ipython-input-7-7fbf5886b6a2> in <module>()
    ----> 1 pd.read_csv(filepath_or_buffer='/Users/ekselan/Desktop/NBA DFS/FantasyLabs_NBAProjections_3_7_2020.csv')

    4 frames
    /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
    1915 kwds["usecols"] = self.usecols
    1916
    -> 1917 self._reader = parsers.TextReader(src, **kwds)
    1918 self.unnamed_cols = self._reader.unnamed_cols
    1919

    pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()

    pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()

    FileNotFoundError: [Errno 2] File b'/Users/ekselan/Desktop/NBA DFS/FantasyLabs_NBAProjections_3_7_2020.csv' does not exist


    I also get the same error when using pd.read_csv(r'/Users/ekselan/Desktop/NBA DFS/FantasyLabs_NBAProjections_3_7_2020.csv')

    Screenshot of the Google colab notebook

    Continue reading...

Compartilhe esta Página