有没有办法将 pptx-python 与 python verion 3.7 一起使用并使用 pyinstaller 制作 exe?
Is there a way to use pptx-python with python verion 3.7 and make exe with pyinstaller?
ppt.py:
from pptx import Presentation
newPPT = Presentation()
newPPT.save("MyPPT.pptx")
正在转换为 exe:cmd == pyinstaller --onefile ppt.py
一旦准备好,错误是:
exception pptx.exc.PackageNotFoundError Raised when a package cannot be found at the specified path.
在 pptx 包的 doc.
有没有办法让它成为可能?
谢谢
我遇到了同样的问题,最后想出了如何根据类似的问题解决它:https://github.com/python-openxml/python-docx/issues/289
解决方法是编辑 spec 文件。
生成规范文件(如果您还没有)运行:
pyi-makespec --onefile yourprogram.py
打开并编辑 sepc 文件:
# -*- mode: python ; coding: utf-8 -*-
import sys # added line
from os import path # added line
site_packages = next(p for p in sys.path if 'site-packages' in p) # added line
block_cipher = None
# add in template in datas
a = Analysis(['your_file.py'],
pathex=['C:\Users\Desktop'],
binaries=[],
datas=[(path.join(site_packages,"pptx","templates"), "pptx/templates")],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
# rest of the file doesn't need any modification
最后生成exe:
pyinstaller your_spec_file.spec
(在 windows 10 机器 运行ning python 3.6.4 上测试)
ppt.py:
from pptx import Presentation
newPPT = Presentation()
newPPT.save("MyPPT.pptx")
正在转换为 exe:cmd == pyinstaller --onefile ppt.py
一旦准备好,错误是:
exception pptx.exc.PackageNotFoundError Raised when a package cannot be found at the specified path.
在 pptx 包的 doc.
有没有办法让它成为可能?
谢谢
我遇到了同样的问题,最后想出了如何根据类似的问题解决它:https://github.com/python-openxml/python-docx/issues/289
解决方法是编辑 spec 文件。 生成规范文件(如果您还没有)运行:
pyi-makespec --onefile yourprogram.py
打开并编辑 sepc 文件:
# -*- mode: python ; coding: utf-8 -*-
import sys # added line
from os import path # added line
site_packages = next(p for p in sys.path if 'site-packages' in p) # added line
block_cipher = None
# add in template in datas
a = Analysis(['your_file.py'],
pathex=['C:\Users\Desktop'],
binaries=[],
datas=[(path.join(site_packages,"pptx","templates"), "pptx/templates")],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
# rest of the file doesn't need any modification
最后生成exe:
pyinstaller your_spec_file.spec
(在 windows 10 机器 运行ning python 3.6.4 上测试)