LoginSignup
4
2

pyinstallerでのpython-pptxのPackage not found at ..\pptx\templates\default.pptxへの対処

Last updated at Posted at 2024-04-26

Windows版のデスクトップアプリを作成しているときに以下のエラーに出会いました。
Package not found at 'C:\Users\ユーザ名\AppData\Local\Temp\_MEI215442\pptx\templates\default.pptx'

python-pptxのdefault.pptxが一時フォルダにないというエラーです。
実際に確認してみると、使っている他のライブラリはC:\Users\ユーザ名\AppData\Local\Temp\_MEI215442以下に存在するのに、pptxだけありませんでした。

解決方法

pyinstallerコマンドを実行したときに生成される.specファイルに以下を記述することで解決しました。
自分はpyenvを使っているので以下のようなパスになっていますが、適宜書き換えてください。

p=r"C:\Users\ユーザ名\.pyenv\pyenv-win\versions\3.9.13\Lib\site-packages\pptx\templates\default.pptx"

a = Analysis(
    ['app.py'],
    pathex=[],
    binaries=[],
    datas=[ (p, '.\\pptx\\templates\\') ],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=True,
)

その後、specファイルを指定して実行します。

pyinstaller App.spec

以上で完了です。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2