Reputation: 724
When I do import docx
with the python-docx
module, I get this error:
Traceback (most recent call last):
File "/Userpath/script.py", line 19, in <module>
import docx
File "/Library/Python/2.7/site-packages/docx/__init__.py", line 3, in <module>
from docx.api import Document # noqa
File "/Library/Python/2.7/site-packages/docx/api.py", line 14, in <module>
from docx.package import Package
File "/Library/Python/2.7/site-packages/docx/package.py", line 11, in <module>
from docx.opc.package import OpcPackage
File "/Library/Python/2.7/site-packages/docx/opc/package.py", line 12, in <module>
from .part import PartFactory
File "/Library/Python/2.7/site-packages/docx/opc/part.py", line 12, in <module>
from .oxml import serialize_part_xml
File "/Library/Python/2.7/site-packages/docx/opc/oxml.py", line 12, in <module>
from lxml import etree
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Library not loaded: libxslt.1.dylib
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Reason: unsafe use of relative rpath libxslt.1.dylib in /Library/Python/2.7/site-packages/lxml/etree.so with restricted binary
Any idea what's going on here?
Upvotes: 0
Views: 928
Reputation: 28883
This is a problem with your lxml
installation.
I expect you get the same answer in Python when you type in the line:
>>> from lxml import etree
Which means it's not related to python-docx
, it's just trying to load a package that's not (or not properly) installed.
Best bet is to search on 'windows install lxml' and learn what you can, but the quick fix might be to uninstall whatever lxml
you have and reinstall it from scratch using a binary distribution from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
Upvotes: 2