No such file or directory: 'c:\\windows\\temp\\test'

Chris Angelico rosuav at gmail.com
Sun Apr 15 05:52:21 EDT 2012


On Sun, Apr 15, 2012 at 7:13 PM, contro opinion <contropinion at gmail.com> wrote:
> in my computer
> C:\Python27>python
> Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on
> win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> 1.
>>>> f=open(r'c:\windows\temp\test','r')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> IOError: [Errno 2] No such file or directory: 'c:\\windows\\temp\\test'
>
> would you mind telling me what's wrong ?

When you open a file with 'r' (to read from it), it has to exist. Try
opening it with 'w' first; that should create the file and let you
write() contents to it. Then close it, and try opening it with 'r'. It
should then work.

ChrisA



More information about the Python-list mailing list