Skip to content
Advertisement

Python WinError 32 The process cannot access the file because it is being used by another process

I made a script that converts pdf files into jpgs and then puts those jpgs in a specific folder. The script works fine so far but, I keep getting an error in the VScode terminal that says :

JavaScript

I tried closing the file before running but, it still does it

JavaScript
JavaScript

Advertisement

Answer

Your script starts by doing

JavaScript

so the process running your script is the one holding the pdfPath directory, and preventing it from being removed by shutil.move. Just do a chdir somewhere else before moving it, for example:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement