0
當我做import docx
與python-docx
模塊,我得到這個錯誤:導入python-docx時出錯?
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
任何想法是怎麼回事?
是,通過命令行發生同樣的錯誤,但即使卸載並重新安裝lxml後,問題仍然存在。我在Mac 10.11上,以供參考。 – user1917407
可能沒有安裝libxml2和libxslt庫:https://stackoverflow.com/a/26544099/1902513 – scanny
這也沒有解決問題:(。這兩個庫安裝成功,沒有錯誤,但原始ERROR與lxml相關並沒有改變 – user1917407