473,591 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi,

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
and os.popen to invoke the external program. Originally I was running
this on cygwin, but also tried under windows.

I'm confused as to why the error would state no such file when opening
in write mode, it should just create the file if it can't find it. I
imagine it has something to do with the external program (its mostly
likely not written very well), but I'm hoping theres a solution to this
that doesn't involve modifying that program. Is it possible that the
file isn't being closed properly? If so, how can I ensure it is
available?

Thanks

Jul 18 '05 #1
6 8759
> 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

Jul 18 '05 #2
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.

Another low-probability cause is that you are trying to create files in
a non-existent directory.

regards
Steve

Jul 18 '05 #3
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.

Jul 18 '05 #4
Could you please post your entire program, if possible?

Thanks!

Jul 18 '05 #5

ha*****@gmail.c om 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.

Jul 18 '05 #6
ha*****@gmail.c om writes:
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
and os.popen to invoke the external program. Originally I was running
this on cygwin, but also tried under windows.


You might be hitting a race condition where the OS is still
considering the file to be in use when you get around to rewriting it,
even if the using application has just exited. I've run into similar
problems when trying to rename temporary files under NT based systems.

The problem can be obscured because some of the Win32-specific IO
errors can turn into more generic IOError exceptions at the Python
level due to incomplete mappings available for all Win32 errors. In
particular, a lot of Win32-layer failures turn into EINVAL errno's at
the C RTL level, which Python in turn translates to ENOENT (which is
the file not found). So the IOError exception at the Python level can
be misleading.

Since it sounds like you can reproduce the problem relatively easily
(just run your application several thousand times), a quick check for
this condition would be to trap the IOError, delay a few seconds (say
5-10 to be absolutely sure, although in the cases I've run into 2-3 is
generally more than enough), and retry the operation. If that
succeeds, then this might be the issue you're hitting.

-- David
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5460
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
0
3031
by: Peter Horwood | last post by:
I am having trouble writing an XML file out on my localhost development machine. I get: Server Error in '/ProblemSolved' Application. ----------------------------------------------------------- --------------------- Access to the path "c:\inetpub\wwwroot\ProblemSolved\XMLData\Products.xml
22
5574
by: Smutny30 | last post by:
Hello, I am preparing a database that will store 10 n * GBs - 100 n * GBs of data. I calculated to have 1,2 GB of bufferpools. I run the DB2 v. 8.2.1 alone on 4 GB box. I obtain : "SQL1478W The defined buffer pools could not be started. Instead, one small
2
3518
by: CM | last post by:
Hi there: I have a web project which can be open and run without problem. I didn't open the web application for a period and during which I didn't modified any IIS items, but now I cannot open any web project even cannot create a new one. The message for create a new web project is: ---------------------- The default web access mode for this project is set to file share, but the project folder at "http://locahost/WebApplication1"cannot be...
0
1762
by: CM | last post by:
Hi there: I have a web project which can be open and run without problem. I didn't open the web application for a period and during which I didn't modified any IIS items, but now I cannot open any web project even cannot create a new one. The message for create a new web project is: (Open an oldASP project got similar error.) My system is Windows 2000 Server ---------------------- The default web access mode for this project is set to...
4
3243
by: CM | last post by:
Hi there: I have a web project which can be open and run without problem. I didn't open the web application for a period and during which I didn't modified any IIS items, but now I cannot open any web project even cannot create a new one. The message for create a new web project is: (Open an oldASP project got similar error.) My system is Windows 2000 Server ---------------------- The default web access mode for this project is set to...
0
3477
by: Sin | last post by:
> Xxxxx : error PRJ0008 : Could not delete file 'd:\xxxxxxx.dll'. > Make sure that the file is not open by another process and is not write-protected. > > LINK : fatal error LNK1168: cannot open ../../Debug/xxxxx.dll for writing > > The file 'xxxxxx.dll' cannot be copied to the run directory. The process cannot > access the file because it is being used by another process. > Could not copy temporary files to the output directory.
3
5814
by: floppyzedolfin | last post by:
Hi there. I'm coding an encryption / decryption program. At this very moment, I think I should be pretty close from the end, but there's something blocking me on my way. There's a "Padding is invalid and cannot be removed" error raised when closing the cryptostream (or FlushFinalBlock-ing it). For what I have read, Padding errors are due to an incorrect padding : PKCS7 is recommended.
6
5990
by: sebastian.noack | last post by:
Hi, is there a way to or at least a reason why I can not use tarfile to create a gzip or bunzip2 compressed archive in the memory? You might might wanna answer "use StringIO" but this isn't such easy as it seems to be. ;) I am using Python 2.5.2, by the way. I think this is a bug in at least in this version of python, but maybe StringIO isn't just file-like enough for this "korky" tarfile module. But this would conflict with its...
0
7934
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7870
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8225
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6639
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5732
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3850
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3891
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1465
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.