I installed PyInstaller to create executables for my python scripts, and that works fine. I used PyPandoc to create .docx
reports, which also run fine when the normal python files are run, but not from the PyInstaller generated executable. It gives the error:
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.
During the executable creation I see no strange issues about PyPandoc. How can I include Pandoc into my executable so others (without Python and/or Pandoc installation) can use the executable and create .docx
reports?
edit: a working process included the following steps:
Create a file including the following code:
import pypandoc pypandoc.convert(source='# Sample title\nPlaceholder', to='docx', format='md', outputfile='test.docx')
Save this file as
pythonfile.py
create an executable with PyInstaller:
pyinstaller --onefile --clean pythonfile.py
Now the executable should run on a computer without Pandoc (or PyPandoc) installed.
pypandoc
only and seems to be working fine in my windows system. Most likely you need to addpypandoc
as a hidden import plus some other dependecy. – Karakulimport pypandoc; pypandoc.convert(source='# Sample title\nPlaceholder', to='docx', format='md', outputfile='test.docx')
. This is saved in a.py
file, which I convert with PyInstaller via the commandpyinstaller --onefile --clean -p H:\AppData\Python\Python27\Lib\site-packages pythonfile.py
– Declared