I recently installed a fresh Anaconda version 2019-10, which uses python 3.7.4.
To be able to read/write MsWord .docx files from within Python I use library module python-docx,
which I installed with:conda install -c conda-forge python-docx
Installed is python-docx 0.8.10.
Now a python script that I frequently used to read/write MsWord .docx files with my previous anaconda installation (with python3.5.4 and python-docx version unknown to me).
script: (shortened)
import docx
doc = docx.Document('demo.docx') # demo.docx exists in same dir
print(len(doc.paragraphs))
suddenly throws an error:
Traceback (most recent call last):
File "D:\pa\Python\ProjectsWorkspace\Py001Proj\src\printenfrompython\wordprinten.py", line 19, in <module>
import docx
File "C:\Users\pa\Anaconda3\lib\site-packages\docx\__init__.py", line 3, in <module>
from docx.api import Document # noqa
File "C:\Users\pa\Anaconda3\lib\site-packages\docx\api.py", line 14, in <module>
from docx.package import Package
File "C:\Users\pa\Anaconda3\lib\site-packages\docx\package.py", line 9, in <module>
from docx.opc.package import OpcPackage
File "C:\Users\pa\Anaconda3\lib\site-packages\docx\opc\package.py", line 9, in <module>
from docx.opc.part import PartFactory
File "C:\Users\pa\Anaconda3\lib\site-packages\docx\opc\part.py", line 12, in <module>
from .oxml import serialize_part_xml
File "C:\Users\pa\Anaconda3\lib\site-packages\docx\opc\oxml.py", line 12, in <module>
from lxml import etree
ImportError: DLL load failed: The specified module could not be found.
Is there a solution to this problem? I cannot go back to my previous installation!
Today I installed python-docx in my plain python3.7.5 installation using: 'pip install python-docx` Now the above error does not occur. Re-installed Anaconda and re-installed python-docx in anaconda with pip and the same error as above occurs. My OS is windows10. I run the test in both cases with Eclipse\PyDev, and switch in PyDev between the python3.7.5 and anaconda python3.7.4 interpreter.