How to Solve NameError: name 'Document' is not defined -- docx

Solution: Import the 'Document' module

To Solve the error, add the following line to the top of your code.

from docx import Document

 

For more information:
Python Document docx