Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running filter pandoc_filter.py #82

Closed
prtome opened this issue Apr 22, 2022 · 7 comments
Closed

Error running filter pandoc_filter.py #82

prtome opened this issue Apr 22, 2022 · 7 comments

Comments

@prtome
Copy link

prtome commented Apr 22, 2022

Describe the bug
I just run jupyter nbconvert --execute --to=docx TOTO.ipynb --output toto.docx

and I obtain the following Traceback

[NbConvertApp] Converting notebook TOTO.ipynb to docx
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/jupyter-nbconvert", line 8, in
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jupyter_core/application.py", line 264, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/traitlets/config/application.py", line 846, in launch_instance
app.start()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 361, in start
self.convert_notebooks()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 533, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 498, in convert_single_notebook
output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbconvert/nbconvertapp.py", line 427, in export_single_notebook
output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbconvert/exporters/exporter.py", line 190, in from_filename
return self.from_file(f, resources=resources, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nbconvert/exporters/exporter.py", line 208, in from_file
return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jupyter_docx_bundler/init.py", line 79, in from_notebook_node
converters.notebookcontent_to_docxbytes(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jupyter_docx_bundler/converters.py", line 298, in notebookcontent_to_docxbytes
pypandoc.convert_file(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pypandoc/init.py", line 150, in convert_file
return _convert_input(source_file, format, 'path', to, extra_args=extra_args,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pypandoc/init.py", line 351, in _convert_input
raise RuntimeError(
RuntimeError: Pandoc died with exitcode "83" during conversion: Error running filter /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/jupyter_docx_bundler/pandoc_filter.py:
Could not find executable python

PYTHON is python3 - does jupyter-docx-bundler need a specific alias for python?

Desktop (please complete the following information):

  • OS: MACOSX 12.3.1
  • Browser safari
  • Versions of Python Python 3.10.2
    all packages installed in march/april
  • Pandoc version pandoc --version
    Pandoc 2.17.1.1
    Compiled with pandoc-types 1.22.1, texmath 0.12.4, skylighting 0.12.2,
    citeproc 0.6.0.1, ipynb 0.2

Additional context
pandoc TOTO.ipynb -s -o new_word_file.docx works perfectly

@m-rossi
Copy link
Owner

m-rossi commented Apr 22, 2022

jupyter-docx-bundler currently does not support pandoc versions above 2.13. There may be some issues. I started some development in #76.

However, this should not have anything to do with not finding python. It is even not clear to me why it tries. I will try to reproduce it and report back.

@m-rossi
Copy link
Owner

m-rossi commented Apr 23, 2022

@prtome I am unable to reproduce this error (also on macOS). Can you provide some details on the installed versions

  • pypandoc
  • pandocfilters
  • nbconvert

If I understand the mechanisms of pancdocfilters correctly, pandoc calls python internally. So it seems like pandoc cannot find the python executable. which python gives you a result?

@prtome
Copy link
Author

prtome commented Apr 23, 2022

pypandoc: 1.7.2
pandocfilters: 1.5.0
nbconvert: 6.4.1

jupyter --version
Selected Jupyter core packages...
IPython : 8.0.1
ipykernel : 6.8.0
ipywidgets : 7.6.5
jupyter_client : 7.1.2
jupyter_core : 4.9.1
jupyter_server : 1.13.4
jupyterlab : not installed
nbclient : 0.5.10
nbconvert : 6.4.1
nbformat : 5.1.3
notebook : 6.4.8
qtconsole : 5.2.2
traitlets : 5.1.1

I am quite new to notebooks - i have done all the installations (Jupiter, pandoc etc, even the latest python, latex) in march/april.

which python gives no result
but which python3 says
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3

i have aliased python to python3
$ type python
python is aliased to `python3'

The last update of macOS (12.3.1) got rid of the python2 installation from apple, so now the python3 is the only one.
As i say if i use pandoc directly to convert to docx it works without problem. I have no idea how/which filter to use on pandoc to try from the command line to see if there is a problem there - i am a newbie on this
thanks

@m-rossi
Copy link
Owner

m-rossi commented Apr 23, 2022

which python gives no result

This may be a problem. I dig into to the pandoc source code and found the following line: https://github.com/jgm/pandoc/blob/b7a44f9d19f547374445bbc0b44e4dfbbca1dca0/src/Text/Pandoc/Filter/JSON.hs#L52 Seems like it is calling python instead of python3. If you make the python command working, this may fix your issue.

As i say if i use pandoc directly to convert to docx it works without problem. I have no idea how/which filter to use on pandoc to try from the command line to see if there is a problem there

pandoc added native support for *.ipynb files a few versions ago. jupyter-docx-bundler does some additional things, like adding-metadata, hiding-inputs-or-complete-code-cells and pandas-html-table-conversion (although this broke with the recent versions). So calling pandoc directly and using jupyter-docx-bundler does something different although both approaches use pandoc under the hood.

@prtome
Copy link
Author

prtome commented Apr 23, 2022

I like jupyter-docx-bundler because i want to hide the source code - not having to manually delete it everytime. so I will find out ow to make which work.
The python command works since it is aliased to python3
python --version
Python 3.10.2

but which does not work - i will try to find out what is going on. Thanks

@prtome
Copy link
Author

prtome commented Apr 23, 2022

I found out - here is what happens. There is no more /usr/bin/python - it was symlinked to python2
What I have done: symlink python to python3 in /usr/local/bin
now which python works
and of course jupyter-docx-bundler also and does exactly what I wanted.
thanks a lot !

@m-rossi
Copy link
Owner

m-rossi commented Apr 23, 2022

Glad, you figured it out

@m-rossi m-rossi closed this as completed Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants