问题
Octave is installed on my iMac in /applications
and works properly.
Emacs is installed on my iMac in /applications
and file editing is possible.
Now I want to run Octave from Emacs. M-xrun-octave
results in:
Searching for program: No such file or directory, octave
In Windows I solved this problem by adding Octave to the environment path, how can I do this on a Mac?
Thank in advance, Hans Sellmeijer
回答1:
Here are two possible solutions:
Find the actual Octave executable by typing
which octave
in your shell. E.g., if installed via Macports it's at/opt/local/bin/octave
. Then, in Emacs, doM-x customize-group RET octave-inferior RET
, edit the value ofInferior Octave Program
to this value and clickState > Save for Future Sessions
.Alternatively, you can do this in Elisp by putting the following in your
.emacs
orinit.el
file (obviously changing the quoted part as necessary):(setq inferior-octave-program "/opt/local/bin/octave")
You can add octave to the PATH environment variable just as on Windows, but Emacs started from the Finder under Mac OS X doesn't get any environment settings that you might have put in
.bashrc
or similar. Either run Emacs from a terminal window, or put in your .emacs:(add-to-list 'exec-path "/opt/local/bin")
Hope that helps.
回答2:
Thanks to Jon, Emacs handles Octave properly on iMac with Snow-Leopard. The ".emacs" file contains:
(add-to-list 'exec-path "/applications/Octave.app/Contents/Resources/bin")
(autoload 'octave-mode "octave-mod" nil t)
(setq auto-mode-alist (cons '("\\.m$" . octave-mode) auto-mode-alist))
(add-hook 'octave-mode-hook (lambda () (abbrev-mode 1) (auto-fill-mode 1) (if (eq window-system 'x) (font-lock-mode 1))))
(autoload 'run-octave "octave-inf" nil t)
Be careful with copying these lines from a .PDF manual. The quote is deformed to escape sequences, which cripples proper use.
回答3:
This is how I was able to get Octave (including plots) running in Emacs on my Mac (OS X 10.7.3):
- Install octave from source:
fink install octave
. This also installed all the dependencies for gnuplot, which the binary distribution does not seem to do correctly (at least, it didn't work for me). Only downside is that the install took several hours to complete on my MacBook Air. - Customize
octave-inferior
in.emacs
: (you may have more variables in this list):
(custom-set-variables '(inferior-octave-program "/sw/bin/octave") '(inferior-octave-startup-args (quote ("-i")))
来源:https://stackoverflow.com/questions/8247072/run-octave-from-emacs-on-imac