import mammoth with open("report.docx", "rb") as docx_file: result = mammoth.convert_to_html(docx_file) html = result.value # The generated HTML messages = result.messages # Any messages, such as warnings during conversion Html_file= open("sampleHTML.html","w") Html_file.write(html) Html_file.close()