python can't remove a file after closing it, "being used by another process" -


I am trying to delete a file after reading it, but receiving "WindowsError: [Error 32] Process file because it is being used by another process "

  file = for the line in the open (self.filePath) file: #do things file.close () os.remove (Self.filePath) # osrename throws error (self.filepath, self.filepath + "old") #throws only error  

any ideas ??

Update: I restarted the box (windows 7), started eclipse, moved to os.remove ("c: \ file \ file.txt"), ran my first line of script, and Found the same error.

2 UPDATE: I used Windows Explorer to navigate the file. For the first time I could not remove it, it was being used by "system". The second attempt was deleted. The correct file is no longer now. Now when I run os.remove ("c: \ file \ file.txt") WindowsError: [Error 32] Can not access the process file because it is used by another process Is being done: 'c: \ file \ file.txt' so I see Windows Explorer and the file comes back, I can delete empty in Explorer, then when I run to delete the script, this error Throws (and empty files Makes). Any ideas that might be here? 3 Update: I'm stupid. I was opening the file at the beginning of an object when I tested "removal" by moving it over the script, I should put it on top, my objects Not after making it

sorry time, I am working at the end of a few weeks which is due to tomorrow and when he will not do it becomes scared

< Div class = "post-text" itemprop = "text">

Another probability is that whenever you delete it or its name If you try to change then a virus checker still opens the file, it is not often, but when this happens, it is really annoying to track it.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -