1

I'm having issues with Python finding an available Executable on my Linux machine. My default PATH includes this Executable (svnlook) but when I run the python script the below function fails to find executable. Any ideas on how to fix this?

def command_output(cmd):
    child  = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
    output = child.communicate()[0]
    return output, child.returncode


def get_author():
    cmd = "svnlook author %s %s %s" % (svn_opt, svn_txn, svn_repo)
    author, return_code = command_output(cmd)

    return author.strip()

Error:

 Traceback (most recent call last):
  File "/home/user/app/csvn/data/repositories/repo/hooks/pre-commit", line 82, in <module>
    author = get_author()
  File "/home/user/app/csvn/data/repositories/repo/hooks/pre-commit", line 53, in get_author
    author, return_code = command_output(cmd)
  File "/home/user/app/csvn/data/repositories/repo/hooks/pre-commit", line 36, in command_output
    child  = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
  File "/home/user/app/activepython-2.7.2.5_x86_64/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/home/user/app/activepython-2.7.2.5_x86_64/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Error: [Errno 2] No such file or directory
4
  • 2
    Please post the full traceback. Commented Nov 2, 2013 at 7:51
  • 2
    You are not finding an executable not a process. Commented Nov 2, 2013 at 8:00
  • @hcwhsa added traceback, any ideas? Commented Nov 2, 2013 at 8:06
  • 1
    Try printing your sys.path from Python and see if the path is passed to Python correctly. In addition try running the svnlook with it's full path and see if it resolves the issue. I'd also make sure that svnlook is not an alias - which is bash internal and can't be passed to a running program. Commented Nov 2, 2013 at 8:08

2 Answers 2

1

You probably want to provide the full path to the executable, e.g. /usr/bin/svnlook or /usr/local/bin/svnlook instead of just svnlook.

See this answer to a related question for details.

Sign up to request clarification or add additional context in comments.

Comments

0

Try running it from the console. Make sure the permissions/executability is correct. Try os.system().

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.