0

The code below gives me FileNotFoundError. I'm running Python 3.5.1 in Jupyter Notebook (installed with Anaconda package). The file test.txt exists in the described folder with a simple text string in it.

  myfile = open(r'C:\Users\324706\test.txt', 'r')

FileNotFoundError

Abdul Fatir
  • 6,159
  • 5
  • 31
  • 58
Murchak
  • 183
  • 1
  • 3
  • 17
  • 2
    You have made a mistake somewhere. The file does not exist, otherwise you wouldn't get that error. – linusg Jun 08 '16 at 17:51
  • I right-clicked on the file and selected properties: it shows location as C:\Users\324706. – Murchak Jun 08 '16 at 17:57
  • You might want to try `import os` and `os.listdir("c:\\Users\\324706")` – Peter Brittain Jun 08 '16 at 17:57
  • Check these questions: [File not found Error in reading text in python](http://stackoverflow.com/questions/19262734/file-not-found-error-in-reading-text-in-python) & [Reading from file in Python, weird error](http://stackoverflow.com/questions/17392863/reading-from-file-in-python-weird-error) – chickity china chinese chicken Jun 08 '16 at 18:01

2 Answers2

0

It looks pretty self explanatory. You don't have the correct destination for the file you're trying to open. Double check where it is and try again.

Mr. DROP TABLE
  • 334
  • 2
  • 9
  • 1
    I guess that would be a possibility. But as is, the file is clearly in the folder shown: C:\Users\324706. I see it, and when I double-click on the file, it opens up with a simple text (the content of the file). – Murchak Jun 08 '16 at 17:59
0

Thank you Peter Brittain, and others. I did that and the file is shown as test.txt.txt.

Murchak
  • 183
  • 1
  • 3
  • 17