Python-docx: raised unexpected: PackageNotFoundError("Package not found at path)

Created on 8 Oct 2018  路  4Comments  路  Source: python-openxml/python-docx

 raised unexpected: PackageNotFoundError("Package not found at '/Users/sskadit/Office/nlpondec2017/newonenv/src/newproject/DATA/C++ Developer/RVAravind_4.doc'",)
Traceback (most recent call last):
  File "/Users/sskadit/Office/nlpondec2017/newenv/src/lib/python3.4/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/Users/sskadit/Office/nlpondec2017/newenv/src/lib/python3.4/site-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
  File "/Users/sskadit/Office/nlpondec2017/newonenv/src/newproject/new/tasks.py", line 78, in test
    doc = docx.Document(inp)
  File "/Users/sskadit/Office/nlpondec2017/newenv/src/lib/python3.4/site-packages/docx/api.py", line 25, in Document
    document_part = Package.open(docx).main_document_part
  File "/Users/sskadit/Office/nlpondec2017/newenv/src/lib/python3.4/site-packages/docx/opc/package.py", line 116, in open
    pkg_reader = PackageReader.from_file(pkg_file)
  File "/Users/sskadit/Office/nlpondec2017/newenv/src/lib/python3.4/site-packages/docx/opc/pkgreader.py", line 32, in from_file
    phys_reader = PhysPkgReader(pkg_file)
  File "/Users/sskadit/Office/nlpondec2017/newenv/src/lib/python3.4/site-packages/docx/opc/phys_pkg.py", line 31, in __new__
    "Package not found at '%s'" % pkg_file
docx.opc.exceptions.PackageNotFoundError: Package not found at '/Users/sskadit/Office/nlpondec2017/newonenv/src/newproject/DATA/C++ Developer/RVAravind_4.doc'

I found the absolute path and relative path to be the same using this in django celery cron to read the doc files

Mac OSX
Python 3.4

Most helpful comment

I have the same issue. My file is .docx and has content in it.

All 4 comments

Any updates here?

There's not enough information here to indicate an error. There are a variety of reasons why this error can arise. In this case it looks like you're trying to open a pre-Office-2007 ".doc" file (rather than a .docx file). python-docx only supports the latter (which is an XML format rather than binary).

You have to write something in the docx file. Then the package can recognize it.

I have the same issue. My file is .docx and has content in it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chcourses picture chcourses  路  3Comments

aekoch picture aekoch  路  7Comments

ronbarak picture ronbarak  路  3Comments

ssuzen picture ssuzen  路  6Comments

scanny picture scanny  路  8Comments