Skip to content
Advertisement

No such file or directory error

This is the error I am getting:

Traceback (most recent call last):
  File "E:stuffmodule.py", line 91, in <module>
    f = open('E:/stuff/log.txt')
IOError: [Errno 2] No such file or directory: 'E:/stuff/log.txt'

And this is my code:

f = open('E:/stuff/log.txt')

The E:/stuff/log.txt file exists. I can navigate in Windows Explorer and open it so why can’t I open it?

EDIT:

Output of DIR command:

C:Documents and SettingsAdministrator>dir e:stuff
 Volume in drive E has no label.
 Volume Serial Number is 5660-4957

 Directory of e:stuff

23. 10. 2010  09:26    <DIR>          .
23. 10. 2010  09:26    <DIR>          ..
19. 10. 2010  20:07               385 index.py
23. 10. 2010  16:12             1 954 module.py
22. 10. 2010  19:16             8 335 backprop.py
19. 10. 2010  20:54             1 307 backprop-input.gif
19. 10. 2010  01:48               310 HelloWorld.kpf
23. 10. 2010  15:47                 0 log.txt.txt
               6 File(s)         12 291 bytes
               2 Dir(s)   8 795 586 560 bytes free



C:Documents and SettingsAdministrator>dir e:
 Volume in drive E has no label.
 Volume Serial Number is 5660-4957

 Directory of e:

16. 10. 2010  13:32    <DIR>          development-tools
23. 10. 2010  09:26    <DIR>          stuff
               0 File(s)              0 bytes
               2 Dir(s)   8 795 586 560 bytes free

I am running the python script from the cmd like this:

python E:stuffmodule.py

Advertisement

Answer

Firstly, from above, Windows supports / just fine.

Secondly: Well, if you look at your file, you’ll notice it’s not log.txt, it’s log.txt.txt… You may see it as “log.txt” in your graphical folder viewer (as opposed to the CLI “dir” command) simply because it hides the known file extensions.

I recommend you disable this – see folder options, there should be an option “Hide extensions of known file types” (or similar).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement