1

I have a problem when calling programs inside a python script. The programs that are giving me problems are those that I have installed manually on my computer and then added them to path on .bashrc file. The programs that where installed using 'sudo apt-get install some_program' don't give me any problem

The programs where added to my .bashrc file as the following way:

#path to fastqc 
export PATH=$PATH:/home/bioinfor3/bin/FastQC/
#path to fastx-toolkits
export PATH=$PATH:/home/bioinfor3/bin/fastx/

Inside my PyCharm, I am using the os module to call those programs the in the below manner:

os.system('fastqc seq.fastq')

And I get this error

sh: 1: fastqc: not found

I guess it has something to do with the sh path or something, but I am not able to make it work

EDIT:

If Pycharm is launched from the terminal, it inherits the bashrc file with my personal paths and it works

Praderas
  • 471
  • 4
  • 14
  • Most likely, PyCharm is not an ancestor of one of your interactive shells. Typically, you should modify your environment from the configuration file for your login shell (`.profile` or `.bash_profile`, as the case may be). – chepner Sep 28 '16 at 14:27

1 Answers1

1

Presumably this is happening because you have modified your login environment to adjust your PATH, but this updated path isn't seen by the shell that's running PyCharm, or PyCharm appears to be nullifying it somehow.

You should first of all verify that

os.system('/home/bioinfor3/bin/FastQC/fastqc seq.fastq')

operates as you would expect (no reason why it shouldn't, but worth checking).

It seems from this answer that by default PyCharm doesn't use bash for its shell but tcsh. Therefore it isn't seeing the setting you are enforcing on bash.

Community
  • 1
  • 1
holdenweb
  • 33,305
  • 7
  • 57
  • 77