【问题标题】:AttributeError when loading pptx module in Python在 Python 中加载 pptx 模块时出现 AttributeError
【发布时间】:2018-12-07 14:36:29
【问题描述】:

尝试导入 python-pptx 模块时,我得到了重复出现的AttributeError

import pptx

AttributeError                            Traceback (most recent call last)
...
----> 8 import pptx.exc as exceptions
...
AttributeError: module 'pptx' has no attribute 'exc'

我正在使用 JupyterNotebook,并且已经使用 pip uninstall python-pptx pip install python-pptx 重新安装了 python-pptx。在stackoverflow上,我找到了一个相关的帖子here

即使我知道它可能没有加载正确的模块,但我不知道如何进一步解决问题。非常感谢您的帮助。

【问题讨论】:

    标签: python python-pptx


    【解决方案1】:

    您是否将您的程序命名为pptx.py? Python 会优先加载该模块而不是库版本。

    您可以在 Python 提示符下找到使用此加载的模块:

    >>> import pptx
    >>> pptx.__file__
    '/somedir/.../python-pptx/pptx/__init__.pyc'
    

    这可能有助于缩小范围。

    【讨论】:

    • 我试过了,模块加载正确。
    猜你喜欢
    • 2015-01-03
    • 2013-08-16
    • 2022-10-05
    • 1970-01-01
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-02
    相关资源
    最近更新 更多