469,903 Members | 1,671 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Re: I/O error 13 Permission denied -Cannot access file as it is usedby another process.

aditya shukla wrote:
Hello folks,

I am creating a python script[windows vista and python2.5] which
accesses another program(prog2).I my python script i am creating a
temporary file and i write the output of prog2
in this temporary file.

temp =
tempfile.NamedTemporaryFile(suffix='_suffix',prefi x='prefix_',dir='C:\\Python25')
- #this how create the temporary file ( i am not closing the temporary
file).This works fine
Why on earth are you *specifying* c:\python25 as the
directory for this file? It's automatically created
in your user-specific temp directory which has specific
permissions and is (obviously) specific to that user.
You may -- depending on your needs -- also not need the
suffix & prefix.

ie, unless you have some specific need in mind, just use:

temp = tempfile.NamedTemporaryFile ()
x= os.path.split(tn)

y=x[1]

Now i search for the file and then try to read this file so that i can
perform some calculations.

This step causes the problem
file=open(find_file,"rb") # find_file is the object returned after
searching the file

error mesage:

the process cannot access the file as another process because it is
being used by another program.(prog2 in this case)
i/o error 13 permission denied

The main stumbling block here is that you're not posting
code you're running, but fragments of code which may or
may not exist in your source. What is tn? What have x
and y to do with anything? What is find_file? And so on.

As far as I can tell you're trying to create a temporary
file, pass its name to another process which writes to
it. You then, in the first process, read the results of
the second process. Is that right?

At the very least, please cut-and-paste a session from
the console which is running the program so that the traceback
is clear.

Thanks
TJG
Aug 28 '08 #1
0 1621

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Colin Graham | last post: by
2 posts views Thread by nospam | last post: by
6 posts views Thread by scottrm | last post: by
1 post views Thread by Praveen | last post: by
2 posts views Thread by FutureShock | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.