Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
I already tried three version: macports, build from sources and the bundled version. All have this problem. So, I guess it has to do with the way emacs interacts with my Python, but I don't know how to debug it. Is there no one here that is a python/orgmode ninja that can give me a hand here? Thanks. Dror On Tue, Jun 2, 2015 at 2:21 PM, Ken Mankoff mank...@gmail.com wrote: Switch to an emacs that doesn't have this bug on your system. Try Homebrew-installed versions (although I know you aren't supposed to mix brew and macports, and I think you use macports). -k. On 2015-06-02 at 01:49, Dror Atariah dror...@gmail.com wrote: No ideas? Please, I really don't know how to tackle this. Thanks. -- Dror Atariah, Ph.D. de.linkedin.com/in/atariah
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
Switch to an emacs that doesn't have this bug on your system. Try Homebrew-installed versions (although I know you aren't supposed to mix brew and macports, and I think you use macports). -k. On 2015-06-02 at 01:49, Dror Atariah dror...@gmail.com wrote: No ideas? Please, I really don't know how to tackle this. Thanks.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
No ideas? Please, I really don't know how to tackle this. Thanks. -- Dror Atariah, PhD Sent from mobile; excuse my brevity. On May 26, 2015 8:39 PM, Dror Atariah dror...@gmail.com wrote: On Tue, May 26, 2015 at 4:02 PM, Ken Mankoff mank...@gmail.com wrote: Where you see everything printed twice. I notice that in addition, you have r/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/py6499_X0''', 'exec')); at the top of your buffer, and I do not. I think the exec might be causing everything to echo as it runs, so everything is printed 2x, and that confuses Org, and it is not able to capture your filename. It is the most promising suspect so far, but still I don't understand where is it coming from? BTW, I noticed that it is not the same directory as the one where the generated temp files are stored.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On Mon, May 25, 2015 at 8:30 PM, John Kitchin jkitc...@andrew.cmu.edu wrote: With emacs -Q, and this org file: #+BEGIN_SRC emacs-lisp (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (python . t))) #+END_SRC #+RESULTS: #+BEGIN_SRC python :session with_matplotlib :results file :exports both import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.savefig('myfig.png') 'myfig.png' #+END_SRC #+RESULTS: [[file:myfig.png]] I get what you expect to happen. In my customized emacs, I get something else that is more like you see. I use emacs that come from MacPorts, so for -Q option I start it using: /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs -Q Your minimal example doesn't work for me, and in the results block I get: #+RESULTS: [[file:]] This is basically, the same problematic result that I get when using my regular initialized emacs. John --- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Mon, May 25, 2015 at 2:22 PM, Dror Atariah dror...@gmail.com wrote: On Mon, May 25, 2015 at 7:29 PM, Ken Mankoff mank...@gmail.com wrote: On 2015-05-25 at 13:25, Dror Atariah dror...@gmail.com wrote: I am sorry for reposting, but I'm still in the dark. Am I the only one who experience this kind of issue? Don't know. Did someone managed to reproduce the problem? I could not reproduce it. Does anyone see this message? :) Yes. Thanks for your reply :) I'm on Mac too, which is where your problem is. Are you starting with emacs -Q? I haven't seen you post a full MWE with both =init.el= and = test.org=. You did provide a test Org file but it wasn't clear to me if that was being used with emacs -Q. I tried to evaluate the problematic file using =emacs -Q= and the problem is the same. Following is the section of my =init.el= that deals with org-mode (if you need more, let me know): --8--8--8--8--8--8--8--8--8--8--8--8--8--8-- ;;; ;; Org Mode related ;;; (setq org-directory ~/Dropbox/org) ;; Set a location for the list of agena files (setq org-agenda-files ~/.emacs.d/agenda_files) ;; Assigns org-mode to .org files (add-to-list 'auto-mode-alist '(\\.org$ . org-mode)) (define-key global-map \C-cl 'org-store-link) (define-key global-map \C-ca 'org-agenda) (setq org-log-done t) (when window-system (require 'org-mouse)) ;; Auto enable flyspell-mode (add-hook 'org-mode-hook 'turn-on-flyspell) ;; Auto fill minor mode in org files (add-hook 'org-mode-hook 'turn-on-auto-fill) ;; Enable org-indent-mode for org buffers (add-hook 'org-mode-hook (lambda ()(org-indent-mode t)) t) ;; Use text-mode abbrev table in org-mode (add-hook 'org-mode-hook '(lambda () (setq local-abbrev-table text-mode-abbrev-table))) ;; Enables selection using SHIFT, while maintaining useful actions ;; related to SHITF in org (setq org-support-shift-select 't) ;; Enable smart qoutes (http://stackoverflow.com/q/15097114/671013) (setq org-export-with-smart-quotes t) ;; Customize the TODO-like keywords (setq org-use-fast-todo-selection t) (setq org-todo-keywords '((sequence TODO(t) PROCESS(p@/!) | DONE(d!) CANCELED(c@ /! (setq org-todo-keyword-faces (quote ((TODO :foreground red :weight bold) (PROCESS :foreground blue :weight bold) (DONE :foreground forest green :weight bold) (CANCELLED :foreground forest green :weight bold (setq org-log-into-drawer t) ;; Capture-org (setq org-default-notes-file (concat org-directory /notes.org)) (define-key global-map \C-cc 'org-capture) (setq org-capture-templates (quote ((t todo entry (file (concat org-directory /gtd.org)) * TODO %?\n%U\n%a\n :clock-in t :clock-resume t) (n note entry (file (concat org-directory /gtd.org)) * %? :NOTE:\n%U\n%a\n :clock-in t :clock-resume t) (j Journal entry (file+datetree (concat org-directory / diary.org)) * %?\n%U\n :clock-in t :clock-resume t) (v Vocabulary entry (file+headline (concat org-directory /vocab.org) Vocabulary) * %^{The word} :drill:\n:PROPERTIES:\n:Part-of-speech: %^{Part of speech|verb|noun|adj|adv}\n:END:\n %t\n %^{Extended word (may be empty)} \n** Answer \n%^{The definition}) ))) ;; Make use of refTeX in org-mode (defun org-mode-reftex-setup () Setups RefTeX to be used with a org file. Code is based on http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/ .
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On 2015-05-26 at 09:11, Dror Atariah dror...@gmail.com wrote: I use emacs that come from MacPorts, so for -Q option I start it using: /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs -Q Consider using different compilation options, and/or a different Emacs.app package. It seems like that might be the easiest way to solve this problem. -k.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On Tue, May 26, 2015 at 3:49 AM, Ken Mankoff mank...@gmail.com wrote: Nick Dokos removed from Cc. On 2015-05-25 at 14:22, Dror Atariah dror...@gmail.com wrote: I tried to evaluate the problematic file using =emacs -Q= and the problem is the same. Sorry I can't help much. It works on my system. The only difference I see is my python version: #+BEGIN_SRC python :session background :results raw import sys sys.version #+END_SRC #+RESULTS: 2.7.9 |Anaconda 2.2.0 (x86_64)| (default, Dec 15 2014, 10:37:34) [GCC 4.2.1 (Apple Inc. build 5577)] I doesn't work also when I try to use the 2.7 version of Python. Following is the section of my =init.el= that deals with org-mode (if you need more, let me know): If the bug exists with emacs -Q, then sending a large init file is just noise and not helpful. A minimum working example would be similar to your previous email, but include the necessary Org setup code to execute Python, and nothing else. I believe this is the example that John provided; which doesn't work for me... How can I make sure that my emacs -Q is really clean? -k. -- Dror Atariah, Ph.D. de.linkedin.com/in/atariah
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On Tue, May 26, 2015 at 3:15 PM, Ken Mankoff mank...@gmail.com wrote: On 2015-05-26 at 09:11, Dror Atariah dror...@gmail.com wrote: I use emacs that come from MacPorts, so for -Q option I start it using: /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs -Q Consider using different compilation options, and/or a different Emacs.app package. It seems like that might be the easiest way to solve this problem. This problem also happens when I use the standard OS X Emacs.app I really don't understand what's going on here. Most likely it has to to with my settings, but how and how to debug is beyond my reach. -k. -- Dror Atariah, Ph.D. de.linkedin.com/in/atariah
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On Mon, May 25, 2015 at 8:30 PM, John Kitchin jkitc...@andrew.cmu.edu wrote: With emacs -Q, and this org file: #+BEGIN_SRC emacs-lisp (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (python . t))) #+END_SRC #+RESULTS: #+BEGIN_SRC python :session with_matplotlib :results file :exports both import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2))# 4 plt.plot([1,3,2]) # 3 plt.savefig('myfig.png') # 2 'myfig.png' # 1 #+END_SRC #+RESULTS: [[file:myfig.png]] As I mentioned before, if I evaluate the second block as-is I get the error. However, if I comment out all the lines except #1 then the code returns the correct results block. Then, I started to add the numbered lines. Adding #2 and #3 still doesn't break the behavior. Once adding line #4 the behavior breaks. Maybe this observation can be helpful? This happens both when starting Emacs -Q or without -Q.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On Tue, May 26, 2015 at 4:02 PM, Ken Mankoff mank...@gmail.com wrote: Where you see everything printed twice. I notice that in addition, you have r/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/py6499_X0''', 'exec')); at the top of your buffer, and I do not. I think the exec might be causing everything to echo as it runs, so everything is printed 2x, and that confuses Org, and it is not able to capture your filename. It is the most promising suspect so far, but still I don't understand where is it coming from? BTW, I noticed that it is not the same directory as the one where the generated temp files are stored.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On 2015-05-26 at 09:18, Dror Atariah dror...@gmail.com wrote: On Tue, May 26, 2015 at 3:49 AM, Ken Mankoff mank...@gmail.com wrote: On 2015-05-25 at 14:22, Dror Atariah dror...@gmail.com wrote: Following is the section of my =init.el= that deals with org-mode (if you need more, let me know): If the bug exists with emacs -Q, then sending a large init file is just noise and not helpful. A minimum working example would be similar to your previous email, but include the necessary Org setup code to execute Python, and nothing else. I believe this is the example that John provided; which doesn't work for me... How can I make sure that my emacs -Q is really clean? Yes John provided a good MWE. Emacs -Q will give you a clean emacs. But we're complicating things by using Python. I just realized mine might not have been totally clean because I had a .pythonrc file that was getting accessed... -k.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On Tue, May 26, 2015 at 4:02 PM, Ken Mankoff mank...@gmail.com wrote: On 2015-05-26 at 09:26, Dror Atariah dror...@gmail.com wrote: #+BEGIN_SRC python :session with_matplotlib :results file :exports both import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2))# 4 plt.plot([1,3,2]) # 3 plt.savefig('myfig.png') # 2 'myfig.png' # 1 #+END_SRC #+RESULTS: [[file:myfig.png]] As I mentioned before, if I evaluate the second block as-is I get the error. However, if I comment out all the lines except #1 then the code returns the correct results block. Then, I started to add the numbered lines. Adding #2 and #3 still doesn't break the behavior. Once adding line #4 the behavior breaks. Maybe this observation can be helpful? This happens both when starting Emacs -Q or without -Q. Still no solution but a few comments: 1) What you write here and on SE are not the same. Please cut-and-paste because details matter. For example, the SE code has import matplotlib.pyplot and then plt.figure but that code crashes because you did not import as plt like you do here... I see. Let's focus on the code posted in this thread and assume that the problem is not related to python mistakes. 2) It seems to be an echo issue. In my *with_matplotlib* buffer in Emacs, I see: #+BEGIN_EXAMPLE Python 2.7.9 |Anaconda 2.2.0 (x86_64)| (default, Dec 15 2014, 10:37:34) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type help, copyright, credits or license for more information. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://binstar.org import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.savefig('myfig.png') 'myfig.png' open('/var/folders/bl/trcxdptd1_q4k6q5fdhvp2m0gn/T/babel-52565cmH/python-525659vF', 'w').write(str(_)) 'org_babel_python_eoe' [matplotlib.lines.Line2D object at 0x10454dd10] 'myfig.png' 'org_babel_python_eoe' #+END_EXAMPLE Where you see everything printed twice. I notice that in addition, you have r/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/py6499_X0''', 'exec')); at the top of your buffer, and I do not. I think the exec might be causing everything to echo as it runs, so everything is printed 2x, and that confuses Org, and it is not able to capture your filename. This sounds like a promising hint. Where is this first line coming from? How can I disable this double printing or figure out why is happening? -k. -- Dror Atariah, Ph.D. de.linkedin.com/in/atariah
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On 2015-05-26 at 09:26, Dror Atariah dror...@gmail.com wrote: #+BEGIN_SRC python :session with_matplotlib :results file :exports both import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2))# 4 plt.plot([1,3,2]) # 3 plt.savefig('myfig.png') # 2 'myfig.png' # 1 #+END_SRC #+RESULTS: [[file:myfig.png]] As I mentioned before, if I evaluate the second block as-is I get the error. However, if I comment out all the lines except #1 then the code returns the correct results block. Then, I started to add the numbered lines. Adding #2 and #3 still doesn't break the behavior. Once adding line #4 the behavior breaks. Maybe this observation can be helpful? This happens both when starting Emacs -Q or without -Q. Still no solution but a few comments: 1) What you write here and on SE are not the same. Please cut-and-paste because details matter. For example, the SE code has import matplotlib.pyplot and then plt.figure but that code crashes because you did not import as plt like you do here... 2) It seems to be an echo issue. In my *with_matplotlib* buffer in Emacs, I see: #+BEGIN_EXAMPLE Python 2.7.9 |Anaconda 2.2.0 (x86_64)| (default, Dec 15 2014, 10:37:34) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type help, copyright, credits or license for more information. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://binstar.org import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.savefig('myfig.png') 'myfig.png' open('/var/folders/bl/trcxdptd1_q4k6q5fdhvp2m0gn/T/babel-52565cmH/python-525659vF', 'w').write(str(_)) 'org_babel_python_eoe' [matplotlib.lines.Line2D object at 0x10454dd10] 'myfig.png' 'org_babel_python_eoe' #+END_EXAMPLE Where you see everything printed twice. I notice that in addition, you have r/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/py6499_X0''', 'exec')); at the top of your buffer, and I do not. I think the exec might be causing everything to echo as it runs, so everything is printed 2x, and that confuses Org, and it is not able to capture your filename. -k.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
I am sorry for reposting, but I'm still in the dark. Am I the only one who experience this kind of issue? Did someone managed to reproduce the problem? Does anyone see this message? :) On Sat, May 23, 2015 at 8:49 PM, Dror Atariah dror...@gmail.com wrote: I am still helpless here. Any idea how to debug the problem? I would be happy to provide any kind of help, but I just cannot do it myself. Further findings: 1) I don't think that matplotlib changes Python's '_', since the tmp file that contains the content of '_' is correct. 2) Somehow, emacs/orgmode fails to extract the filename. 3) It doesn't work also when using emacs 24.5 and orgmode 8.2.10. Following is an org file that tries to summarize the issue: #+TITLE: Integrate matplotlib figures in an org mode buffer * Goal The ultimate goal is to use org-babel as a replacement of IPython. The first motivation is to enable an easier version controling of the document. The first challenge I faced is integration of plots returned by ~matplotlib~ in the org buffer. * Capturing filename I would like to use (babel) orgmode as an interactive python notebook. Therefore, in order to allow the various code blocks to know each other, it is important to use the ~:session~ option. However, once ~:session~ is used, together with ~matplotlib~ the desired behavior is no longer in place. * Clean testing, no Matplotlib For the sake of testing, the following merely suppose to return the filename #+BEGIN_SRC python :session no_matplotlib :results file :exports both x = 'hello ' y = 'world' z = x + y 'foo.bar' #+END_SRC #+RESULTS: [[file:foo.bar]] *Passed* Indeed, the ~RESULTS~ block contains a link to the filename indicated by the last string. * Importing Matplotlib The following minimal example should generate a simple figure, ~myfig.png~, and orgmode should capture it and interpret it as a filename to be used by the following ~RESULTS~ block. #+BEGIN_SRC python :session with_matplotlib :results file :exports both import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.savefig('myfig.png') 'myfig.png' #+END_SRC #+RESULTS: [[file:]] *Failed!* This time, it doesn't work anymore. The file ~myfig.png~ is properly generated, but the last string is not captured by ~matplotlib~. Following is the content of the corresponding interactive python session: #+BEGIN_SRC Process with_matplotlib finished Python 3.4.3 (default, Mar 10 2015, 14:53:35) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin Type help, copyright, credits or license for more information. , '''/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/py32771xVI''', 'exec')); import matplotlib import matplotlib matplotlib.use('Agg') matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.plot([1,3,2]) plt.savefig('myfig.png') plt.savefig('myfig.png') 'myfig.png' 'myfig.png' open('/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/babel-32771x4j/python-32771-fO', 'w').write(str(_)) open('/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/babel-32771x4j/python-32771-fO', 'w').write(str(_)) 'org_babel_python_eoe' 'org_babel_python_eoe' [matplotlib.lines.Line2D object at 0x108e01828] 'myfig.png' 9 'org_babel_python_eoe' #+END_SRC * Some background ** Python Version #+BEGIN_SRC python :session background :results raw import sys sys.version #+END_SRC #+RESULTS: 3.4.3 (default, Mar 10 2015, 14:53:35) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] ** Matplotlib version #+BEGIN_SRC python :session background :results raw import matplotlib matplotlib.__version__ #+END_SRC #+RESULTS: 1.4.3 ** System I am running Emacs version ~GNU Emacs 24.5.1 (x86_64-apple-darwin14.1.0, NS apple-appkit-1344.72) of 2015-04-19 on tenten-slave.macports.org~ The orgmode version is: ~Org-mode version 8.2.10 (8.2.10-40-gc763fa-elpaplus @ /Users/drorata/.emacs.d/elpa/org-plus-contrib-20150518/)~ ** Stackoverflow reference I also posted a question in the SE network: [[ http://emacs.stackexchange.com/questions/11075/org-mode-python-session-does-not-return-a-file-name ]] * Question So, my question is how to tackle/debug this issue? Can someone give me a hand here? That would be really great! Thanks! -- Dror Atariah, Ph.D. de.linkedin.com/in/atariah
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
With emacs -Q, and this org file: #+BEGIN_SRC emacs-lisp (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (python . t))) #+END_SRC #+RESULTS: #+BEGIN_SRC python :session with_matplotlib :results file :exports both import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.savefig('myfig.png') 'myfig.png' #+END_SRC #+RESULTS: [[file:myfig.png]] I get what you expect to happen. In my customized emacs, I get something else that is more like you see. John --- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Mon, May 25, 2015 at 2:22 PM, Dror Atariah dror...@gmail.com wrote: On Mon, May 25, 2015 at 7:29 PM, Ken Mankoff mank...@gmail.com wrote: On 2015-05-25 at 13:25, Dror Atariah dror...@gmail.com wrote: I am sorry for reposting, but I'm still in the dark. Am I the only one who experience this kind of issue? Don't know. Did someone managed to reproduce the problem? I could not reproduce it. Does anyone see this message? :) Yes. Thanks for your reply :) I'm on Mac too, which is where your problem is. Are you starting with emacs -Q? I haven't seen you post a full MWE with both =init.el= and = test.org=. You did provide a test Org file but it wasn't clear to me if that was being used with emacs -Q. I tried to evaluate the problematic file using =emacs -Q= and the problem is the same. Following is the section of my =init.el= that deals with org-mode (if you need more, let me know): --8--8--8--8--8--8--8--8--8--8--8--8--8--8-- ;;; ;; Org Mode related ;;; (setq org-directory ~/Dropbox/org) ;; Set a location for the list of agena files (setq org-agenda-files ~/.emacs.d/agenda_files) ;; Assigns org-mode to .org files (add-to-list 'auto-mode-alist '(\\.org$ . org-mode)) (define-key global-map \C-cl 'org-store-link) (define-key global-map \C-ca 'org-agenda) (setq org-log-done t) (when window-system (require 'org-mouse)) ;; Auto enable flyspell-mode (add-hook 'org-mode-hook 'turn-on-flyspell) ;; Auto fill minor mode in org files (add-hook 'org-mode-hook 'turn-on-auto-fill) ;; Enable org-indent-mode for org buffers (add-hook 'org-mode-hook (lambda ()(org-indent-mode t)) t) ;; Use text-mode abbrev table in org-mode (add-hook 'org-mode-hook '(lambda () (setq local-abbrev-table text-mode-abbrev-table))) ;; Enables selection using SHIFT, while maintaining useful actions ;; related to SHITF in org (setq org-support-shift-select 't) ;; Enable smart qoutes (http://stackoverflow.com/q/15097114/671013) (setq org-export-with-smart-quotes t) ;; Customize the TODO-like keywords (setq org-use-fast-todo-selection t) (setq org-todo-keywords '((sequence TODO(t) PROCESS(p@/!) | DONE(d!) CANCELED(c@ /! (setq org-todo-keyword-faces (quote ((TODO :foreground red :weight bold) (PROCESS :foreground blue :weight bold) (DONE :foreground forest green :weight bold) (CANCELLED :foreground forest green :weight bold (setq org-log-into-drawer t) ;; Capture-org (setq org-default-notes-file (concat org-directory /notes.org)) (define-key global-map \C-cc 'org-capture) (setq org-capture-templates (quote ((t todo entry (file (concat org-directory /gtd.org)) * TODO %?\n%U\n%a\n :clock-in t :clock-resume t) (n note entry (file (concat org-directory /gtd.org)) * %? :NOTE:\n%U\n%a\n :clock-in t :clock-resume t) (j Journal entry (file+datetree (concat org-directory / diary.org)) * %?\n%U\n :clock-in t :clock-resume t) (v Vocabulary entry (file+headline (concat org-directory /vocab.org) Vocabulary) * %^{The word} :drill:\n:PROPERTIES:\n:Part-of-speech: %^{Part of speech|verb|noun|adj|adv}\n:END:\n %t\n %^{Extended word (may be empty)} \n** Answer \n%^{The definition}) ))) ;; Make use of refTeX in org-mode (defun org-mode-reftex-setup () Setups RefTeX to be used with a org file. Code is based on http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/. Once you run this, you will be asked to set a master file of the org. (interactive) (load-library reftex) (and (buffer-file-name) (file-exists-p (buffer-file-name)) (reftex-parse-all)) (define-key org-mode-map (kbd C-c )) 'reftex-citation) ) ;; Open indirect buffer in new frame (setq org-indirect-buffer-display 'new-frame) ;; Set common TAGS ;; Check:
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On 2015-05-25 at 13:25, Dror Atariah dror...@gmail.com wrote: I am sorry for reposting, but I'm still in the dark. Am I the only one who experience this kind of issue? Don't know. Did someone managed to reproduce the problem? I could not reproduce it. Does anyone see this message? :) Yes. I'm on Mac too, which is where your problem is. Are you starting with emacs -Q? I haven't seen you post a full MWE with both =init.el= and =test.org=. You did provide a test Org file but it wasn't clear to me if that was being used with emacs -Q. -k.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
On Mon, May 25, 2015 at 7:29 PM, Ken Mankoff mank...@gmail.com wrote: On 2015-05-25 at 13:25, Dror Atariah dror...@gmail.com wrote: I am sorry for reposting, but I'm still in the dark. Am I the only one who experience this kind of issue? Don't know. Did someone managed to reproduce the problem? I could not reproduce it. Does anyone see this message? :) Yes. Thanks for your reply :) I'm on Mac too, which is where your problem is. Are you starting with emacs -Q? I haven't seen you post a full MWE with both =init.el= and = test.org=. You did provide a test Org file but it wasn't clear to me if that was being used with emacs -Q. I tried to evaluate the problematic file using =emacs -Q= and the problem is the same. Following is the section of my =init.el= that deals with org-mode (if you need more, let me know): --8--8--8--8--8--8--8--8--8--8--8--8--8--8-- ;;; ;; Org Mode related ;;; (setq org-directory ~/Dropbox/org) ;; Set a location for the list of agena files (setq org-agenda-files ~/.emacs.d/agenda_files) ;; Assigns org-mode to .org files (add-to-list 'auto-mode-alist '(\\.org$ . org-mode)) (define-key global-map \C-cl 'org-store-link) (define-key global-map \C-ca 'org-agenda) (setq org-log-done t) (when window-system (require 'org-mouse)) ;; Auto enable flyspell-mode (add-hook 'org-mode-hook 'turn-on-flyspell) ;; Auto fill minor mode in org files (add-hook 'org-mode-hook 'turn-on-auto-fill) ;; Enable org-indent-mode for org buffers (add-hook 'org-mode-hook (lambda ()(org-indent-mode t)) t) ;; Use text-mode abbrev table in org-mode (add-hook 'org-mode-hook '(lambda () (setq local-abbrev-table text-mode-abbrev-table))) ;; Enables selection using SHIFT, while maintaining useful actions ;; related to SHITF in org (setq org-support-shift-select 't) ;; Enable smart qoutes (http://stackoverflow.com/q/15097114/671013) (setq org-export-with-smart-quotes t) ;; Customize the TODO-like keywords (setq org-use-fast-todo-selection t) (setq org-todo-keywords '((sequence TODO(t) PROCESS(p@/!) | DONE(d!) CANCELED(c@ /! (setq org-todo-keyword-faces (quote ((TODO :foreground red :weight bold) (PROCESS :foreground blue :weight bold) (DONE :foreground forest green :weight bold) (CANCELLED :foreground forest green :weight bold (setq org-log-into-drawer t) ;; Capture-org (setq org-default-notes-file (concat org-directory /notes.org)) (define-key global-map \C-cc 'org-capture) (setq org-capture-templates (quote ((t todo entry (file (concat org-directory /gtd.org)) * TODO %?\n%U\n%a\n :clock-in t :clock-resume t) (n note entry (file (concat org-directory /gtd.org)) * %? :NOTE:\n%U\n%a\n :clock-in t :clock-resume t) (j Journal entry (file+datetree (concat org-directory / diary.org)) * %?\n%U\n :clock-in t :clock-resume t) (v Vocabulary entry (file+headline (concat org-directory /vocab.org) Vocabulary) * %^{The word} :drill:\n:PROPERTIES:\n:Part-of-speech: %^{Part of speech|verb|noun|adj|adv}\n:END:\n %t\n %^{Extended word (may be empty)} \n** Answer \n%^{The definition}) ))) ;; Make use of refTeX in org-mode (defun org-mode-reftex-setup () Setups RefTeX to be used with a org file. Code is based on http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/. Once you run this, you will be asked to set a master file of the org. (interactive) (load-library reftex) (and (buffer-file-name) (file-exists-p (buffer-file-name)) (reftex-parse-all)) (define-key org-mode-map (kbd C-c )) 'reftex-citation) ) ;; Open indirect buffer in new frame (setq org-indirect-buffer-display 'new-frame) ;; Set common TAGS ;; Check: http://sachachua.com/blog/2008/01/tagging-in-org-plus-bonus-code-for-timeclocks-and-tags/ (setq org-tag-alist '( (PRIVATE . ?p) (:startgroup . nil) (WORK .?w) (:grouptags . nil) (WORK@mittagseminar . ?m) (WORK@open_questions . ?i) (WORK@diss . ?d) (WORK@CV . nil) (:endgroup . nil) (:startgroup . nil) (IT . ?I) (:grouptags . nil) (IT@emacs . nil) (IT@git . nil) (IT@TeX . nil) (:endgroup . nil) (:startgroup . nil) (PROG . ?p) (:grouptags . nil) (PROG@mathematica . nil) (PROG@cgal . nil)
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
Nick Dokos removed from Cc. On 2015-05-25 at 14:22, Dror Atariah dror...@gmail.com wrote: I tried to evaluate the problematic file using =emacs -Q= and the problem is the same. Sorry I can't help much. It works on my system. The only difference I see is my python version: #+BEGIN_SRC python :session background :results raw import sys sys.version #+END_SRC #+RESULTS: 2.7.9 |Anaconda 2.2.0 (x86_64)| (default, Dec 15 2014, 10:37:34) [GCC 4.2.1 (Apple Inc. build 5577)] Following is the section of my =init.el= that deals with org-mode (if you need more, let me know): If the bug exists with emacs -Q, then sending a large init file is just noise and not helpful. A minimum working example would be similar to your previous email, but include the necessary Org setup code to execute Python, and nothing else. -k.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
I am still helpless here. Any idea how to debug the problem? I would be happy to provide any kind of help, but I just cannot do it myself. Further findings: 1) I don't think that matplotlib changes Python's '_', since the tmp file that contains the content of '_' is correct. 2) Somehow, emacs/orgmode fails to extract the filename. 3) It doesn't work also when using emacs 24.5 and orgmode 8.2.10. Following is an org file that tries to summarize the issue: #+TITLE: Integrate matplotlib figures in an org mode buffer * Goal The ultimate goal is to use org-babel as a replacement of IPython. The first motivation is to enable an easier version controling of the document. The first challenge I faced is integration of plots returned by ~matplotlib~ in the org buffer. * Capturing filename I would like to use (babel) orgmode as an interactive python notebook. Therefore, in order to allow the various code blocks to know each other, it is important to use the ~:session~ option. However, once ~:session~ is used, together with ~matplotlib~ the desired behavior is no longer in place. * Clean testing, no Matplotlib For the sake of testing, the following merely suppose to return the filename #+BEGIN_SRC python :session no_matplotlib :results file :exports both x = 'hello ' y = 'world' z = x + y 'foo.bar' #+END_SRC #+RESULTS: [[file:foo.bar]] *Passed* Indeed, the ~RESULTS~ block contains a link to the filename indicated by the last string. * Importing Matplotlib The following minimal example should generate a simple figure, ~myfig.png~, and orgmode should capture it and interpret it as a filename to be used by the following ~RESULTS~ block. #+BEGIN_SRC python :session with_matplotlib :results file :exports both import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.savefig('myfig.png') 'myfig.png' #+END_SRC #+RESULTS: [[file:]] *Failed!* This time, it doesn't work anymore. The file ~myfig.png~ is properly generated, but the last string is not captured by ~matplotlib~. Following is the content of the corresponding interactive python session: #+BEGIN_SRC Process with_matplotlib finished Python 3.4.3 (default, Mar 10 2015, 14:53:35) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin Type help, copyright, credits or license for more information. , '''/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/py32771xVI''', 'exec')); import matplotlib import matplotlib matplotlib.use('Agg') matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.plot([1,3,2]) plt.savefig('myfig.png') plt.savefig('myfig.png') 'myfig.png' 'myfig.png' open('/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/babel-32771x4j/python-32771-fO', 'w').write(str(_)) open('/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/babel-32771x4j/python-32771-fO', 'w').write(str(_)) 'org_babel_python_eoe' 'org_babel_python_eoe' [matplotlib.lines.Line2D object at 0x108e01828] 'myfig.png' 9 'org_babel_python_eoe' #+END_SRC * Some background ** Python Version #+BEGIN_SRC python :session background :results raw import sys sys.version #+END_SRC #+RESULTS: 3.4.3 (default, Mar 10 2015, 14:53:35) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] ** Matplotlib version #+BEGIN_SRC python :session background :results raw import matplotlib matplotlib.__version__ #+END_SRC #+RESULTS: 1.4.3 ** System I am running Emacs version ~GNU Emacs 24.5.1 (x86_64-apple-darwin14.1.0, NS apple-appkit-1344.72) of 2015-04-19 on tenten-slave.macports.org~ The orgmode version is: ~Org-mode version 8.2.10 (8.2.10-40-gc763fa-elpaplus @ /Users/drorata/.emacs.d/elpa/org-plus-contrib-20150518/)~ ** Stackoverflow reference I also posted a question in the SE network: [[ http://emacs.stackexchange.com/questions/11075/org-mode-python-session-does-not-return-a-file-name ]] * Question So, my question is how to tackle/debug this issue? Can someone give me a hand here? That would be really great! Thanks!
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
Obviously, I have the directory in place, and the file is actually saved properly in it. The version is use is: Org-mode version 8.2.10 (8.2.10-40-gc763fa-elpaplus @ /Users/drorata/.emacs.d/elpa/org-plus-contrib-20150504/) Finally, here is the output that I have in the python interactive session: ---8---8---8---8---8---8---8---8---8---8---8---8--- import matplotlib import matplotlib matplotlib.use('Agg') matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) plt.plot([1,3,2]) fig.tight_layout() fig.tight_layout() plt.savefig('images/myfig.png') plt.savefig('images/myfig.png') 'images/myfig.png' # return this to org-mode 'images/myfig.png' # return this to org-mode open('/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/babel-22151hFS/python-22151B4O', 'w').write(str(_)) open('/var/folders/kz/1c2cxn1x60n_t5p2j1p02b18gn/T/babel-22151hFS/python-22151B4O', 'w').write(str(_)) 'org_babel_python_eoe' 'org_babel_python_eoe' [matplotlib.lines.Line2D object at 0x10ebb6eb8] 'images/myfig.png' 16 'org_babel_python_eoe' ---8---8---8---8---8---8---8---8---8---8---8---8--- From this it seems like the right thing happens, but still org doesn't manage to capture it. I'm still in the dark. At work I manage to get the images inserted properly and it is simply fabulous! I want it also on my mac!!! :) Thanks in advance, Dror On Sat, May 2, 2015 at 7:11 PM, Nick Dokos ndo...@gmail.com wrote: Dror Atariah dror...@gmail.com writes: How can I solve this problem? I should have added: ... after I create the images directory. I don't think the savefig() can do that.
[O] [Orgmode] Unable to capture the file name generated using matplotlib
Consider the following example (from the documentation): ---8---8---8---8---8---8---8---8---8--- #+begin_src python :session :results file import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) fig.tight_layout() plt.savefig('images/myfig.pdf') 'images/myfig.pdf' # return this to org-mode #+end_src ---8---8---8---8---8---8---8---8---8--- It should return something like ---8---8---8---8---8---8---8---8---8--- #+RESULTS: [[file:images/myfig.pdf]] ---8---8---8---8---8---8---8---8---8--- But for me it returns merely ---8---8---8---8---8---8---8---8---8--- #+RESULTS: [[file:]] ---8---8---8---8---8---8---8---8---8--- That is, it doesn't capture the file name that should be the last evaluation. How can I solve this problem?
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
Dror Atariah dror...@gmail.com writes: How can I solve this problem? I should have added: ... after I create the images directory. I don't think the savefig() can do that.
Re: [O] [Orgmode] Unable to capture the file name generated using matplotlib
Dror Atariah dror...@gmail.com writes: Consider the following example (from the documentation): ---8---8---8---8---8---8---8---8---8--- #+begin_src python :session :results file import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(figsize=(3,2)) plt.plot([1,3,2]) fig.tight_layout() plt.savefig('images/myfig.pdf') 'images/myfig.pdf' # return this to org-mode #+end_src ---8---8---8---8---8---8---8---8---8--- It should return something like ---8---8---8---8---8---8---8---8---8--- #+RESULTS: [[file:images/myfig.pdf]] ---8---8---8---8---8---8---8---8---8--- But for me it returns merely ---8---8---8---8---8---8---8---8---8--- #+RESULTS: [[file:]] ---8---8---8---8---8---8---8---8---8--- That is, it doesn't capture the file name that should be the last evaluation. How can I solve this problem? What version are you running? For me, it works fine: Org-mode version 8.3beta (release_8.3beta-1023-g49e054 @ /home/nick/elisp/org-mode/lisp/) Nick