subprocess.call not working from pyCharm

2019-07-08 03:15发布

问题:

My file structure is:

├── src
│   ├── main
│   │   ├── costSensitiveClassifier.py
└── vowpal.sh
|
├── data
│   ├── output
│   │   ├── cost
|   |   |_______openCostClassifier.dat
|   |   |   

And within costSensitiveClassifier.py, I essentially am trying to run a script called vowpal.sh that does some manipulations on openCostClassifer.dat and outputs some files into the same folder as that file.

The code within costSensitiveClassifier.py is:

import subprocess
print "Starting cost sensitive predictions using batch script\n"
subprocess.call("../../vowpal.sh")
print "Ending predictions"

And the code within vowpal.sh is:

# !/bin/bash
vw --csoaa 24 data/output/cost/openCostClassifier.dat -f data/output/cost/csoaa.model
vw -t -i data/output/cost/csoaa.model data/output/cost/openCostClassifier.dat -p data/output/cost/csoaa.predict

Note, I am running costSensitiveClassifier.py within pyCharm, and my error is:

Traceback (most recent call last):

  File "/Users/me/Documents/university/anonymous/src/main/costSensitiveClassifier.py", line 324, in <module>
    subprocess.call("../../vowpal.sh")
  File "/Users/me/anaconda/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/Users/me/anaconda/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/Users/me/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

Here is the vowpal wabbit tutorial.