2

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.

Dhruv Ghulati
  • 2,976
  • 3
  • 35
  • 51
  • 1
    Does your `vowpal.sh` script have a [shebang](http://stackoverflow.com/questions/25165808/should-i-use-a-shebang-with-bash-scripts) `#!/bin/bash` as the first line? – chickity china chinese chicken Aug 03 '16 at 18:13
  • 3
    @DhruvGhulati `# !/bin/bash` is not acceptable. The first two characters of your script must be exactly `#!`. You can have `#!/bin/bash` or `#! /bin/bash`, just not what you wrote. – Dunes Aug 03 '16 at 21:27
  • Wow that was the answer..(sigh) – Dhruv Ghulati Aug 03 '16 at 22:31
  • Note, now the problem comes in what is running in my bash script: `vw (./io_buf.h:123): can't open: data/output/cost/csoaa.modelerrno = No such file or directory`. This is because my python script is not waiting for the bash script I called to finish running and output these new files e.g. `csoaa.model` – Dhruv Ghulati Aug 03 '16 at 22:34

0 Answers0