0

I am having trouble figuring this out. I want to module load an aligner-"bowtie" in this case. Below is a snippet of the code I have:

import subprocess
moduleCmd=['module', 'load','/modules/ogi-mbc/software/bowtie/bowtie2-2.2.4/bowtie2']
subprocess.Popen(moduleCmd,shell=True)

When I run my script, I am getting following message:

cmdModule.c(166):ERROR:11: Usage is 'module command  [arguments ...]

Modules Release 3.2.10 2012-12-21 (Copyright GNU GPL v2 1991):

Usage: module [ switches ] [ subcommand ] [subcommand-args ]`

The program is NOT loaded after running the script.

Testing a simple command with subprocess such as:

testCmd=['ls', '-l']
subprocess.Popen(testCmd,shell=True)

I get the expected output.

Soviut
  • 88,194
  • 49
  • 192
  • 260
sudeep
  • 21
  • 2
  • Please update your answer and format your code properly with the built in editor tools. Also, please add an explanation of what you expect the code to do as well as the result you're getting. – Soviut May 29 '17 at 01:14
  • 1
    Possible duplicate of [Why subprocess.Popen doesn't work when args is sequence?](https://stackoverflow.com/questions/2400878/why-subprocess-popen-doesnt-work-when-args-is-sequence), and a [bunch](https://stackoverflow.com/questions/20140137/passing-variables-to-subprocess-popen) of [other](https://stackoverflow.com/questions/20140137/passing-variables-to-subprocess-popen) SO questions. –  May 29 '17 at 02:02

1 Answers1

0

Getting a cue from [link] (Loading environment modules within a python script)

Following worked: cmd=os.popen("/usr/bin/modulecmd python load bowtie/2.2.4) exec(cmd))

Incase others face the same issue, as nothing else was working.

NOTE: using python/2.7.3, also others environment modules worked for other tools as well.

sudeep
  • 21
  • 2