Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docx library doesn't recognizes Document method

Tags:

python

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
like image 565
user3511563 Avatar asked Aug 05 '14 11:08

user3511563


1 Answers

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.

like image 50
WeaselFox Avatar answered Oct 15 '22 10:10

WeaselFox