user3511563
user3511563

Reputation: 397

Docx library doesn't recognizes Document method

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

Answers (1)

WeaselFox
WeaselFox

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

Related Questions