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

This is a discussion on Re: I/O error 13 Permission denied -Cannot access file as it is usedby another process. within the Python forums in Programming Languages category; 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 ...

Go Back   Application Development Forum > Programming Languages > Python

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-28-2008, 04:13 AM
Tim Golden
Guest
 
Default 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
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:25 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.