subprocess.call(....) can't find file

This works from the command line but not within pycharm with run in console. I have tried specifying the full path to the file still did not work. I am not actually sure what can't be found.


from subprocess import call
call(["muscle", "-in", "h09389.fasta",  "-out", "temp/aligned09389.fasta"])
################################################################
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2538, in run_code
    exec code_obj in self.user_global_ns, self.user_ns
  File "<ipython-input-111-0bcbb395c050>", line 1, in <module>
    call(["muscle", "-in", "h09389.fasta",  "-out", "temp/aligned09389.fasta"])
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/subprocess.py", line 493, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
prettyPrint();


When run from command line.

>>> from subprocess import call
>>> call(["muscle", "-in", "h09389.fasta",  "-out", "temp/aligned09389.fasta"])

MUSCLE v3.8.31 by Robert C. Edgar

http://www.drive5.com/muscle
This software is donated to the public domain.
Please cite: Edgar, R.C. Nucleic Acids Res 32(5), 1792-97.
......
prettyPrint();
4 comments
Please add the directory containing the 'muscle' tool to the global PATH, as described in http://serverfault.com/questions/16355/how-to-set-global-path-on-os-x
0
I assume it is because if I type muscle into terminal it works. Is the Global path different?

$ muscle

MUSCLE v3.8.31 by Robert C. Edgar

http://www.drive5.com/muscle
This software is donated to the public domain.
Please cite: Edgar, R.C. Nucleic Acids Res 32(5), 1792-97.
prettyPrint();

I tend to struggle with path issues so maybe I am missing something. muscle was installed using brew.

Thanks
Vincent
0
muscle is in /usr/local/bin
$ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
prettyPrint();
0
The /etc/paths file is loaded only by the shell. Since PyCharm is not normally started from the shell, it doesn't see the environment variables defined in /etc/paths. Please follow the link I've posted to see how to define environment variables in a way that will be visible both to the shell and to PyCharm.
0

Please sign in to leave a comment.