简体   繁体   中英

SublimeREPL + Octave

I am using Octave for some Machine Learning work and I have noticed in my package library in Sublime that there is SublimeREPL: Octave as an option. However when I select it, I get the following error message:

FileNotFoundError(2, "No such file or directory: octave")

Is there a way to use sublime to code with Octave?

Many thanks

First, you need to find out where your octave executable lives, and note the full path to it. On Linux or OS X, open your favorite terminal emulator and type which octave , and if it's in your $PATH variable it will print the full path to it (for example, /opt/local/bin/octave or something like that). If it's not in your path, or if you're on Windows, you'll have to search around a bit until you find octave or octave.exe , if you're on Windows.

Once you have the path, open Sublime and select Preferences -> Browse Packages... , which will open your Packages folder (surprisingly). Navigate to Packages/SublimeREPL/config/Octave and open the Main.sublime-menu file in Sublime - don't worry, it's just plain JSON. Go down to line 18 (or thereabouts) - it should say "cmd": ["octave", "-i"], . Change "octave" to "/full/path/to/octave" , obviously replacing /full/path/to/ with the actual full path you noted earlier.

Save the file, and you should be all set. Tools -> SublimeREPL -> Octave should now open up an interactive session, just like running octave -i on the command line would do. You can use all of the usual SublimeREPL shortcuts to send code to the running REPL, or just use if for testing functions, code snippets, etc.

Have fun!

I am using Sublime Text 3 on OS X

Octave programs are running perfectly. So you can try the below mentioned steps

Open Sublime

Goto Tools --> Build System --> New Build System...

Paste this code

{
"cmd": ["/usr/local/octave/3.8.0/bin/octave-3.8.0", "$file"],
"selector": "source.m"
}

Save it as Octave.sublime-build

Now use Octave as your build system

Use ⌘ + B to run your code.

Enjoy!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM