Я пытаюсь удалить указанный c файл из каталога со следующим кодом:
def PPTtoPDF(inputFileName = 'presentation.pptx', outputFileName = 'presentation.pdf', formatType = 32):
try:
os.remove(os.path.abspath(outputFileName))
except:
pass
powerpoint = comtypes.client.CreateObject("Powerpoint.Application")
powerpoint.Visible = 1
if outputFileName[-3:] != 'pdf':
outputFileName = outputFileName + ".pdf"
deck = powerpoint.Presentations.Open(os.path.abspath(inputFileName))
deck.SaveAs(outputFileName, formatType) # formatType = 32 for ppt to pdf
deck.Close()
powerpoint.Quit()
return os.path.abspath(outputFileName)
И получаю следующую ошибку:
FileNotFoundError Traceback (most recent call last)
<ipython-input-123-c809253c599e> in <module>
----> 1 pdf_file = PPTtoPDF()
~\Documents\ppt.py in PPTtoPDF(inputFileName, outputFileName, formatType)
129 try:
--> 130 os.remove(os.path.abspath(outputFileName))
131 except:
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\...\\presentation.pdf'
Любая помощь будет очень ценится