Python can’t find file

I am having great difficulty getting python 3.4 to recognize a path or text file on a windows 8 system. I have tried a variety of different approaches but get the similar errors (which likely implies something simple regarding the syntax).

The file itself is located in the same folder as the script file trying to open it: C:\Users\User\Desktop\Python stuff\Data.txt

for simplicity, the simplest means to access the file (at least that I know of) is f=open

These lines were coded as:

f = open("Data.txt", "r")

and

f = open("C:/Users/User/Desktop/Python stuff/Data.txt", "r") 

but return the error:

Traceback (most recent call last):
  File "C:\Users\User\Desktop\Python stuff\Testscript.py", line 3, in <module>
    f = open("C:/Users/User/Desktop/Python stuff/Data.txt", "r")
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/U

Leave a Comment