jkitchin / ox-ipynb

org-mode exporter to Jupyter notebooks
170 stars 39 forks source link

Error on basic file #13

Closed guilherme-salome closed 5 years ago

guilherme-salome commented 5 years ago

I am trying to get ox-ipynb running but I am running into a error when opening an exported file. The .org file is simply:

Hello world!
#+BEGIN_SRC python
  print("Hello")
#+END_SRC

I export it using ox-ipynb and when I open the file in jupyter I get the error: Unreadable Notebook: /Users/guilhermesalome/Desktop/test.ipynb TypeError('pop() takes at most 1 argument (2 given)').

Does anyone have any ideas on what could be causing this and how I can fix it? Thanks! :D

jkitchin commented 5 years ago

you need to change python to ipython in your src block. ox-ipynb does not support python blocks.

guilherme-salome commented 5 years ago

@jkitchin Thanks! Indeed now it works. I was trying to use python in the code block to be able to C-' and edit the code with my existing configs.

fleimgruber commented 11 months ago

@jkitchin Do you see a good way to support python source blocks? For example, I am using emacs-jupyter and there is the convenience of being able to just use "python" as the language, even if it gets interpreted as jupyter-python, reference: https://github.com/emacs-jupyter/jupyter#overriding-built-in-src-block-languages.

jkitchin commented 11 months ago

I think if you add this to your init file you can export python blocks:

(push '(python . (kernelspec . ((display_name . "Python 3")
                                (language . "python")
                                (name . "python3"))))
      ox-ipynb-kernelspecs)

(push '(python . (language_info . ((codemirror_mode . ((name . ipython)
                               (version . 3)))
                                   (file_extension . ".py")
                                   (mimetype . "text/x-python")
                                   (name . "python")
                                   (nbconvert_exporter . "python")
                                   (pygments_lexer . "ipython3")
                                   (version . "3.5.2"))))
      ox-ipynb-language-infos)

My initial light testing works, but it seems the results are stripped. I don't have time to dig into this now, if it is a big deal, please open a new issue.

fleimgruber commented 11 months ago

Thanks a lot, works over here! Also, stripping the results would have been my preferred default, so no need for a separate issue.