I've been stuck on a peculiar error for several hours, searching for solutions in Google and failing, probably because the problem is so specific, but it actually has broader implications, which is why I've been trying hard to fix it.
I am using Python 2.6 and can use the subprocess.call()
to run a program called STAMP in the vanilla Python terminal, or even the iPython terminal as such:
>>>Import subprocess
>>>subprocess.call('stamp')
That works fine, but when I execute the same thing via sublime text 2 (ST2) using it's sublimeREPL plug-in for python or iPython (Tools>sublimeREPL>Python>...) it fails with the following error:
> Traceback (most recent call last): File "<stdin>", line 1, in
> <module> File "<string>", line 27, in <module> File
> "/usr/lib64/python2.6/subprocess.py", line 478, in call
> p = Popen(*popenargs, **kwargs) File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
> errread, errwrite) File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child
> raise child_exception OSError: [Errno 2] No such file or directory
Which is the same error it gives when you call a program that is not installed on the system. It seems paradoxical that this error does not appear for any other installed programs/commands that I've tested other than 'stamp' (so you would think sublimeREPL is working fine), and yet running subprocess.call('stamp') does work in the native python terminal, as well as iPython (so you would think stamp is working/installed fine). The only clue I had in mind was that I had to install stamp using g++
Summary:
Extra info:
Step 1: Install the GNU Scientific Library. Download from http://www.gnu.org/software/gsl/ Add the 'include' and 'lib' directories to your PATH.
Step 2: Compile the STAMP code. Use a command such as the following:
g++ -O3 -o stamp Motif.cpp Alignment.cpp ColumnComp.cpp \ PlatformSupport.cpp PlatformTesting.cpp Tree.cpp \ NeuralTree.cpp MultipleAlignment.cpp RandPSSMGen.cpp \ ProteinDomains.cpp main.cpp -lm -lgsl -lgslcblas Note: if the GSL library is not in the PATH, add the appropriate directories using the -L and -I compiler options.
Step 3: Test it out!
Converting my comment to answer form so that it's clearer that the problem was solved:
PATH is not set inside the sublimeREPL terminal. If you provide the full path to the stamp executable, subprocess.call
will work fine.