Fixing Python Pandas pandas.read_csv FileNotFoundError: File b’\xe2\x80\xaa (or the relevant path) does not exist.

Python Pandas pandas.read_csv FileNotFoundError: File b’\xe2\x80\xaa (or the relevant path) does not exist is an error which occurs when you try to use the function pd.read_csv() to load a .csv file in an incorrect way.

In this blog post I attempt to present a clear explanation of why this error takes place and how you to solve it, I am also going to explain other ways to solve the error if possible.

Exploring the Error : Python Pandas pandas.read_csv FileNotFoundError: File b’\xe2\x80\xaa (or the relevant path) does not exist.

This is an error which occurs when you try to use the function pd.read_csv() to load a .csv file in an incorrect way.

Do not mix between errors. Make sure the error message looks like the error message bellow

                                                                       #
FileNotFoundError: File b'\xe2\x80\xaaC:/Users/user/Desktop/myfile.csv' (or the relevant path) does not exist.
                                                                       #

Bellow is a number of tested solutions that I have tried and that have worked for me.

Solution 1 : Run your python code from the correct location

The problem usually occurs because of an incorrect path. Sometimes, even when the path is correct the error still happens, the error happens because of a very sneaky reason.

Let us consider an example where we have a csv file called mylist.csv, the file is located in the directory : ~/.

Let us assume that inside the directory we have a folder called myprojects, the path to my projects is : ~/myprojects/

mycode.py is a python file that resides in ~/myprojects/ , our goal is to load mylist.csv from mycode.py like this.

                                                                       #
import pandas as pd
mydataframe = pd.read_csv('../mylist.csv')
                                                                       #

This is the most Important part to understand.

Even when the path is correct, the error can happen if you run your python file from the wrong location.

If you move to the directory ~/myprojects/ and then run

                                                                       #
python mycode.py
                                                                       #

Everything should work fine and the error should be gone.

if you are in the directory ~/ and you run the command

                                                                       #
python myprojects/mycode.py
                                                                       #

You will run into the same issue we have just proposed a solution to.

I hope you follow the best practices above, if that did not fix the issue please try the second method bellow.

Solution 2 : use a raw string before the path

Using a raw string before the path is a solution that can be very useful. You can use just like in the example bellow.

                                                                       #
pd.read_csv(r'C:\Users\...\Desktop\mylist.csv')
                                                                       #

If I were you, I would not be surprised if this method did solve your error, this is a very effective way to deal with the problem.

Thank you for reading this entire article, I hope your error is gone or at least I guided you in a good direction.

Summing-up : 

Here we are at the end of the road, at the end of this article, if you solved the error : Python Pandas pandas read csv FileNotFoundError File b’\xe2\x80\xaa or the relevant path does not exist, this was a confusing error for me the first time I encountered it.

Thank you for reading my blog post to the end, If you want to learn more about the Python programming language, check out the official Python Documentation : https://docs.python.org/3/