Error In Python Ioerror: [errno 2] No Such File Or Directory: 'data.csv'
In Python, I have a script, I'm trying to use the python open('data.csv') command to open a CSV file that I have in the Python script directory. There is a file there called data.
Solution 1:
Try to give the full path to your csv file
open('/users/gcameron/Desktop/map/data.csv')
The python process is looking for file in the directory it is running from.
Solution 2:
open looks in the current working directory, which in your case is ~
, since you are calling your script from the ~
directory.
You can fix the problem by either
cd
ing to the directory containingdata.csv
before executing the script, orby using the full path to
data.csv
in your script, or- by calling os.chdir(...) to change the current working directory from within your script. Note that all subsequent commands that use the current working directory (e.g.
open
andos.listdir
) may be affected by this.
Solution 3:
It's looking for the file in the current directory.
First, go to that directory
cd /users/gcameron/Desktop/map
And then try to run it
python colorize_svg.py
Solution 4:
You need to either provide the absolute path to data.csv, or run your script in the same directory as data.csv.
Post a Comment for "Error In Python Ioerror: [errno 2] No Such File Or Directory: 'data.csv'"