cx_freeze / pptx“PackageNotFoundError”

时间:2013-06-19 08:19:23

标签: python python-2.7 powerpoint cx-freeze

我正在使用模块“pptx”(编辑和操作powerpoint)的Python程序。程序在解释器中没有问题,但是一旦我把它作为.exe文件(用cx_freeze或py2exe构建)启动,当我点击主按钮时,我有这个错误信息:

Exception in Tkinter callback
Traceback (most recent call last):
File "Tkinter.pyc", line 1470, in __call__
File "pptx_02.py", line 187, in ButtonErstellen
File "pptx\api.pyc", line 29, in __init__
File "pptx\presentation.pyc", line 87, in __init__
File "pptx\presentation.pyc", line 170, in __open
File "pptx\packaging.pyc", line 88, in open
File "pptx\packaging.pyc", line 671, in __new__
PackageNotFoundError: Package not found at 'C:\Users\Moi\Programmation\Python\build\exe.win32-2.7\library.zip\pptx\templates\default.pptx' 

问题是该地址实际存在“default.pptx”文件。

在查看“pptx”的功能时,我可能已经知道了这个问题的原因(但不知道解决方案)。 对于最后一个错误:文件“pptx \ packaging.pyc”,第671行, new
是以下代码:

class FileSystem(object):
    """
    Factory for filesystem interface instances.

    A FileSystem object provides access to on-disk package items via their URI
    (e.g. ``/_rels/.rels`` or ``/ppt/presentation.xml``). This allows parts to
    be accessed directly by part name, which for a part is identical to its
    item URI. The complexities of translating URIs into file paths or zip item
    names, and file and zip file access specifics are all hidden by the
    filesystem class. |FileSystem| acts as the Factory, returning the
    appropriate concrete filesystem class depending on what it finds at *path*.
    """
    def __new__(cls, file):
        # if *file* is a string, treat it as a path
        if isinstance(file, basestring):
            path = file
            if is_zipfile(path):
                fs = ZipFileSystem(path)
            elif os.path.isdir(path):
                fs = DirectoryFileSystem(path)
            else:
                raise PackageNotFoundError("Package not found at '%s'" % path)
        else:
            fs = ZipFileSystem(file)
        return fs

问题可能是最终文件(default.pptx)不是zip,而是zip。但我不知道如何解决这个问题,或者问题是否真的存在问题。

如果有人作为一个想法...

谢谢!

0 个答案:

没有答案