Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python-docx: 'package not found'

I have a doc.docx file at '/var/code/oa'. I need to read it use python-docx. I write this:

from docx import Document
document = Document('/var/code/oa/doc.docx')

then, have error.. PackageNotFoundError: Package not found at '/var/code/oa/doc.docx'

why?

Thanks @soon. Uh, It's stupid. the reason is the file, it's must be docx file. I just change the file name from doc to docx, it's not a really docx file.

like image 249
ooooh326 Avatar asked Sep 01 '14 08:09

ooooh326


1 Answers

If there is nothing in your doc.docx, it will raise PackageNotFoundError. Try to put something in it and do it again. Meanwhile, an invalid docx file will cause this error too. Tell me if it works.

like image 179
Stephen Lin Avatar answered Oct 19 '22 04:10

Stephen Lin