Reputation: 397
I'm trying to use docx library, but I'm getting this error:
AttributeError: 'module' object has no attribute 'Document'
This is my code:
import docx
document = docx.Document('file.docx')
What is happening? I already used document in other computers. I installed docx library using pip:
pip install docx
Upvotes: 6
Views: 3843
Reputation: 7390
your'e confusing package docx
with the package python-docx
.
pip install python-docx
>>> import docx
>>> docx.Document
<class 'docx.api.Document'>
But you are right the naming here is a problem.
Upvotes: 12