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

后端 未结 4 1342
南笙
南笙 2020-12-18 21:41

I am trying to remove a file after reading from it, but getting \"WindowsError: [Error 32] The process cannot access the file because it is being used by another process\"

相关标签:
4条回答
  • 2020-12-18 22:20

    There are lots of possible reasons for this. However, the most likely one is that you have a directory window open that contains the file, or that such a window was closed recently and Windows has yet to flush the directory from its cache. Try closing any directory window that you were looking in and try again.

    0 讨论(0)
  • 2020-12-18 22:25

    Another possibility is that a virus checker still has the file open at the time you try to delete or rename it. This doesn't happen often but when it does, it's really annoying to track down.

    0 讨论(0)
  • 2020-12-18 22:34

    I have the same problem right now with an access-AB. Process Explorer shows that .. 'python.exe' is using the file that I wish to delete. I can not kill Python. It is an annoying solution.

    0 讨论(0)
  • 2020-12-18 22:38

    Use Unlocker(easier) or Process Explorer to see what program has the file open.

    (as suggested by Anon)

    0 讨论(0)
提交回复
热议问题