0

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:

  1. subprocess.call('stamp') works in a native python terminal
  2. subprocess.call('stamp') does not work in ST2's sublimeREPL python terminal
  3. subprocess.call() seems to work fine in both sublimeREPL or native python terminal

Extra info:

  • Python 2.6.3
  • Installation procedure for stamp:

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!

hello_there_andy
  • 2,039
  • 2
  • 21
  • 51
  • 1
    PATH is probably not set inside the sublimeREPL terminal. Does using the full path to stamp (probably /usr/bin/stamp or /usr/local/bin/stamp) work? – dano May 01 '14 at 17:11
  • @dano well the code for stamp is stored in `/home/ab108/software/STAMP.v1.2/code/` and following the instructions using g++ it seems that after compiling with GNU it's associated the code with the alias `stamp` and i've added to PATH, with `export PATH=$PATH:/home/ab108/software/STAMP.v1.2/code/`. When running `subprocess.call('/home/ab108/software/STAMP.v1.2/code/')` i get: `OSError: [Errno 13] Permission denied` – hello_there_andy May 01 '14 at 17:32
  • 1
    You want `subprocess.call('/home/ab108/software/STAMP.v1.2/code/stamp')` – dano May 01 '14 at 17:35
  • that worked!! thank you so much! and thank you for the explanation in your first comment – hello_there_andy May 01 '14 at 17:35

1 Answers1

2

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.

dano
  • 91,354
  • 19
  • 222
  • 219