Python スクリプトの実行可能ファイルを作成するために PyInstaller をインストールしましたが、問題なく動作します。PyPandoc を使用して.docx
レポートを作成しました。これは、通常の python ファイルが実行されたときにも正常に実行されますが、PyInstaller によって生成された実行可能ファイルからではありません。エラーが発生します:
Traceback (most recent call last):
File "src\flexmodel_postcalc.py", line 295, in postcalculate_everything
File "src\flexmodel_postcalc.py", line 281, in generate_report_docx
File "src\flexmodel_report_docx.py", line 118, in generate_text_useages_docx
File "pypandoc\__init__.py", line 50, in convert
File "pypandoc\__init__.py", line 70, in _convert
File "pypandoc\__init__.py", line 197, in get_pandoc_formats
File "pypandoc\__init__.py", line 336, in _ensure_pandoc_path
OSError: No pandoc was found: either install pandoc and add it
to your PATH or install pypandoc wheels with included pandoc.
実行可能ファイルの作成中に、PyPandoc に関する奇妙な問題は見られません。実行可能ファイルに Pandoc を含めて、(Python や Pandoc をインストールしていない) 他のユーザーが実行可能ファイルを使用して.docx
レポートを作成できるようにするにはどうすればよいですか?
編集: 作業プロセスには次の手順が含まれていました:
次のコードを含むファイルを作成します。
import pypandoc pypandoc.convert(source='# Sample title\nPlaceholder', to='docx', format='md', outputfile='test.docx')
このファイルを名前を付けて保存
pythonfile.py
PyInstaller で実行可能ファイルを作成します。
pyinstaller --onefile --clean pythonfile.py
これで、実行可能ファイルは、Pandoc (または PyPandoc) がインストールされていないコンピューターで実行されるはずです。