Home > OS >  How to fix FileNotFoundError: [Errno 2] No such file or directory: no
How to fix FileNotFoundError: [Errno 2] No such file or directory: no

Time:10-17

I am trying to open a file from my local disk in Jupter. I used to see the output but since a couple of days ago it brings the file not found error. I can still see the file on the path provided above. any help? thanks

import numpy as np
import pandas as pd
from pandas import DataFrame 
import scipy.stats as stats
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

adf=pd.read_csv('C:/Users/New folder/churn.csv')
adf.head()

CodePudding user response:

Try this:

adf=pd.read_csv('C:\\Users\\New folder\\churn.csv')

CodePudding user response:

The path you are using is more UNIX based, on Windows, you need to use double backslashes.

C:\\Location\\file_is_here.csv

There is another way around it, consists of using pathlib

from pathlib import Path
your_file_path = Path().joinpath('C', 'Location', 'file_is_here.csv')

This will take care of slashes for you

  • Related