5 ms·
I use org-mode all the time and do a lot of plotting with Python and matplotlib and for some reason the snippet #+BEGIN_SRC python :var fname="delseepy.png"
by ldx77 6y ago
I use org-mode all the time and do a lot of plotting with Python and matplotlib and for some reason the snippet
#+BEGIN_SRC python :var fname="delseepy.png" :var delsee=delsee :results file
import matplotlib.pyplot as plt
x, y, z = zip(\*delsee)
fig = plt.figure()
axes = fig.add_subplot(1,1,1)
axes.plot(y, z, marker='o')
fig.savefig(fname)
return fname
#+END_SRC
has never worked for me. I have to remove the "return" keyword on the last line. Not sure if this is an org-mode issue or related to the Python version (the author seems to be using Python 2).
- neolog 6y agoIs each block converted into a function? Otherwise it's a syntax error.
- sahkopoyta 6y agoYes they are, for me that exact snippet is fine
- deleted 6y ago[deleted]
- superbcarrot 6y agoThis has been my limited experience with everything related to Emacs - fragmented tutorials on how to do x that work with someone's specific setup. And when you start looking around for fixes you get solutions for "this is how I do this with Prelude", "this is built-in", "my customized Spacemacs setup..." and at that point I throw my hands in the air, admit to myself that I'm not a real man and go back to VSCode.
- rcdwealth 6y agoIt is so. Emacs contains the full Emacs manual, non-fragmented, compact and complete, including the full Org mode manual, non-fragmented. It is self-documenting program. Users can learn what is built-in feature and what exists before starting to use extensions. If you try to do too much at once, of course, you are prone to give up as you started on a too high gradient.
- Jeff_Brown 6y agoI think I'm a pretty adept emacs user, and I've relied at least ten times more on crappy informal documentation in blogs, StackOverflow etc. than on the real stuff.
- JHonaker 6y agoI do that too, but out of habit from other pursuits rather than a real necessity. Recently, I've found myself going to Emacs and packages' internal help first, and I usually find what I'm looking for. Despite me spending several years not believing it, it's really good documentation for the most part.
- nanna 6y ago> admit to myself that I'm not a real man Note, many emacs users aren't men at all.
- deleted 6y ago[deleted]
- superbcarrot 6y agoI know. It's a figure of speech, not a reference to the demographics of emacs users.
- Y_Y 6y agocertainly not, they are gods
- Thibi2000 6y agoYou might have to check the value of =org-babel-python-wrapper-method=, which defines the format of the created temporary file to which the source block is exported so it can be executed properly. After installing matplotlib using pip3 and changing =org-babel-python-command= to python3 I was able to execute this example without a problem. The value of =org-babel-python-wrapper-method= for me is: def main(): %s open('%s', 'w').write( str(main()) )"
- danieldk 6y agoI have found that over time org documents tend to become coupled somewhat to your Emacs configuration and are not generally portable. I guess this is the reason why many org example snippets on the net do not really work exactly the same.
- tobbe2064 6y agoThere is a package which lets you interact with ipython kernels instead. You might want to check that out. https://github.com/nnicandro/emacs-jupyter https://github.com/nnicandro/emacs-jupyter
- nprescott 6y agoI have tried with both python 2.7.18 and python 3.8.6 using Emacs 27.1 and the excerpt works without issue for me; I have no configuration (emacs -Q) beyond pointing org to my virtual environment and allowing python evaluation in org-babel: (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) (setq org-babel-python-command "~/mpl-venv/bin/python") Are you perhaps on an outdated version of Emacs? There have been a few different fixes around the "last line" return value over the years[0][1] but I can't really remember something like your example not working for me personally. [0]: https://lists.gnu.org/archive/html/emacs-orgmode/2017-11/msg00274.html https://lists.gnu.org/archive/html/emacs-orgmode/2017-11/msg... [1]: https://orgmode.org/list/87pnfdo88v.fsf@gmail.com/t/#u https://orgmode.org/list/87pnfdo88v.fsf@gmail.com/t/#u