cannot open file in write mode, no such file or directory

John Machin sjmachin at lexicon.net
Mon Feb 28 16:12:20 EST 2005


haynesc at gmail.com wrote:
> Kartic wrote:
> > > I'm having a problem where when trying to open a file in write
> mode,
> > I
> > > get an IOError stating no such file or directory.  I'm calling an
> > > external program which takes an input file and produces an output
> > file
> > > repeatedly, simulating the input file separately for each
> replicate.
> > > The error occurs when trying to open the input file to write out
> the
> > > new data.  The problem is difficult to reproduce since it only
> shows
> > up
> > > once every few thousand replicates.  I've tried using both
> os.system
> >
> > I am afraid you need to give more information that just IOError,
> > calling an external program.
> >
> > Please post the exact message including the input filename at the
> time
> > the program went down. If you don't print the filename, please
modify
> > your program to do so.
> >
> > A shot in the dark solution to your problem might be that you are
> > dynamically  generating a filename and that filename probably
> contains
> > characters not allowed by the local file system OR you generate a
> path
> > that does not exist. For open() to work with the 'w' flag, the path
> > where the file you say should be created should exist.
> >
> > Thanks,
> > -Kartic
>
> Sorry, here is the exact error:
>
> Traceback (most recent call last):
>  File "hapSim.py", line 415, in ?
>    run(REPLICATES, dsSelection, permuteStatus, sigThreshold
>  File "hapSim.py", line 354, in run
>    createInput(dt)
>  File "hapSim.py", line 178, in createInput
>    inF = open(IN_FNAME, "w")
> IOError: [Errno 2] No such file or directory: 'prog.input'
>
> I am using the same file name repeatedly, it works fine the first few
> thousand times, but eventually gives this error.

1. Exactly how many is "few thousand"? Is it the same number each time?
Does the problem still happen if you don't run the external program,
but just create the input file a few thousand times?

2. Which version of Windows are you using, and what type of filesystem?
When it dies, how many files exist in the directory where you are
trying to create "prog.input"? Reason for asking: I vaguely recall
problems with FAT-type filesystems where there was a rather low limit
on the number of files that could be recorded in a directory, PLUS a
rather misleading "errno" being returned when one hit the limit.




More information about the Python-list mailing list