前提・実現したいこと
Pyinstallerで、StreamlitのPythonスクリプトをexe化しようとしてハマっています。
発生している問題・エラーメッセージ
2022-01-12 23:04:14.475 INFO matplotlib.font_manager: Failed to extract font properties from /System/Library/Fonts/Apple Color Emoji.ttc: In FT2Font: Could not set the fontsize (error code 0x17) 2022-01-12 23:04:14.754 INFO matplotlib.font_manager: Failed to extract font properties from /System/Library/Fonts/Supplemental/NISC18030.ttf: In FT2Font: Could not set the fontsize (error code 0x17) 2022-01-12 23:04:15.013 INFO matplotlib.font_manager: Failed to extract font properties from /System/Library/Fonts/LastResort.otf: tuple indices must be integers or slices, not str 2022-01-12 23:04:15.269 INFO matplotlib.font_manager: generated new fontManager Traceback (most recent call last): File "run_streamlit.py", line 2, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "streamlit/__init__.py", line 76, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "streamlit/delta_generator.py", line 71, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "streamlit/elements/arrow_altair.py", line 23, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "altair/__init__.py", line 4, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "altair/vegalite/__init__.py", line 2, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "altair/vegalite/v4/__init__.py", line 2, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "altair/vegalite/v4/schema/__init__.py", line 2, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "altair/vegalite/v4/schema/core.py", line 4, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "altair/utils/__init__.py", line 1, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "altair/utils/core.py", line 13, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "jsonschema/__init__.py", line 29, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "jsonschema/protocols.py", line 18, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "jsonschema/validators.py", line 348, in <module> File "jsonschema/_utils.py", line 61, in load_schema File "pathlib.py", line 1236, in read_text File "pathlib.py", line 1222, in open File "pathlib.py", line 1078, in _opener FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/rc/pnkfc6zd6_56b55jxf6zzyhr0000gn/T/_MEIFuSRqn/jsonschema/schemas/draft3.json' [33085] Failed to execute script 'run_streamlit' due to unhandled exception!
該当のソースコード
以下が実際に動作させたいmain.pyです。
main.py
1import streamlit as st 2 3 4def main(): 5 st.write('Hello, World!') 6 7 8if __name__ == '__main__': 9 main()
試したこと
main.pyをそのままexe化してもうまく動作しないため、以下のrun_streamlit.pyをexe化させることで対応しようとしています。
run_streamlit.py
1import subprocess 2import streamlit as st 3 4subprocess.call('streamlit run main.py', shell=True)
ただしこのままだとこちらのエラーが発生するため、更に以下のhook-streamlit.pyを同ディレクトリに置くことで対応していますが、先述の別エラーにハマってしまっています。
from PyInstaller.utils.hooks import copy_metadata datas = copy_metadata('streamlit')
あなたの回答
tips
プレビュー