为什么我无法在Python 3.5中导入pptx包

时间:2017-04-16 07:20:46

标签: python

我设法使用'pip install python-pptx'安装python-pptx 0.6.5,但是当我“从pptx import Presentation”时,它报告了错误。任何人都可以帮助我吗?错误报告如下:

Traceback (most recent call last):
  File "Course_1.py", line 1, in <module>
    from pptx import Presentation
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pptx/__init__.py", line 15, in <module>
    from pptx.api import Presentation  # noqa
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pptx/api.py", line 17, in <module>
    from .package import Package
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pptx/package.py", line 13, in <module>
    from .opc.package import OpcPackage
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pptx/opc/package.py", line 13, in <module>
    from .oxml import CT_Relationships, serialize_part_xml
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pptx/opc/oxml.py", line 12, in <module>
    from lxml import etree
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/lxml/etree.cpython-35m-darwin.so, 2): Library not loaded: libxml2.2.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/lxml/etree.cpython-35m-darwin.so
  Reason: Incompatible library version: etree.cpython-35m-darwin.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0  

1 个答案:

答案 0 :(得分:-1)

反过来尝试:from pptx import Presentation