I'm working on Ubuntu 12.4 and I have matlab installed. Typically, in order to invoke matlab from terminal I have to type in '~/MATLAB/bin/matlab'. Obviously this is a bit annoying so I aliased this command by adding
alias matlab='sh ~/MATLAB/bin/matlab'
to .bashrc. Now everything is golden and typing 'matlab' in the terminal (bash) works from any directory.
The problem arises when I'm trying to invoke Matlab from a python script. having a statement like this:
>>> commands.getoutput('matlab')
'sh: 1: matlab: not found'
as it seems the alias is not being recognized. Just to make sure:
>>> commands.getoutput('~/MATLAB/bin/matlab')
works like a charm, and
>>> commands.getoutput('echo $SHELL')
'/bin/bash'
indeed verifies that python is trying to execute the cmd in bash...
Any idea what's happening here? why isn't the alias being recognized? how/can it be fixed?
Thanks!
Add the matlab binary path to your PATH environment variable.
PATH=~/MATLAB/bin/:$PATH
export PATH
Then python would find matlab:
>>> commands.getoutput('matlab')
I think commands doesn't know of your shell's current aliases. However environment variables such as PATH persist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With