Package not found error on windows in python-docx?
<p>I'm getting an error when I try to access files from my working directory. This is not a duplicate of @dsphoebe 's question, because the file I try to open is certainly a .docx file and for whatever reason, I can't open it.</p>

<pre><code>rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
for subdir, dirs, files in os.walk(rootdir):
    for file in files:
        print(file)    #prints all word docs in my folder, just like I want
</code></pre>

<p>Now when I replace that print statement with a statement that creates a docx object,</p>

<pre><code>rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
for subdir, dirs, files in os.walk(rootdir):
    for file in files:
        doc = docx.Document(os.path.join(rootdir, file))
        ...
        #continuing with what I wanted to do w/ the documents...

Error: "Package not found at '%s'" % pkg_file
docx.opc.exceptions.PackageNotFoundError: Package not found at 'my doc.docx'
</code></pre>

<p>Now, in that mydocs folder, my doc.docx is the proper title and it certainly is a .docx file. This certain file's title is composed of <strong>2 words</strong> with one space (ie. my doc.docx). But the conversion to a type 'Document' object <strong>works</strong> for another word doc in that same folder that is only <strong>ONE</strong> word!</p>

<p>This works:</p>

<pre><code>    rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
    doc = docx.Document(os.path.join(rootdir, "Access.docx"))
    Exited with code = 0
</code></pre>

<p>But this doesn't:</p>

<pre><code>    rootdir = 'C:\\Users\\me\\Documents\\Python\\mydocs\\'
    doc = docx.Document(os.path.join(rootdir, "Able2Extract Professional.docx"))
    Exited with code=1
</code></pre>

<p>So <code>two words.docx</code> wouldn't work but <code>oneword.docx</code> would. Very confusing. Anyone know how to diagnose this problem?</p>