I’m trying to run jira-agile-metrics using Python’s subprocess module but keep getting an error. Here’s my code:
for project in project_list:
process = subprocess.Popen(["jira-agile-metrics", project], stdout=subprocess.PIPE)
result = process.communicate()[0]
The error I’m getting is FileNotFoundError: [Errno 2] No such file or directory: 'jira-agile-metrics'. I’ve already installed the jira-agile-metrics package on my system. What could be causing this problem and how do I fix it? The command works fine when I run it directly in the terminal, but fails when called from Python.
Had the same headache recently! Try adding shell=True to your subprocess call - sometimes helps when the command isn’t found in PATH. Also check if you’re running from a different environment than where you installed it. Could be a venv issue.
I encountered similar issues with subprocess and command-line tools installed via pip. The problem often lies in the fact that subprocess is unable to locate executables installed in non-standard locations. To resolve this, consider using shutil.which() which helps dynamically find the executable’s path:
import shutil
import subprocess
jira_cmd = shutil.which('jira-agile-metrics')
if jira_cmd:
process = subprocess.Popen([jira_cmd, project], stdout=subprocess.PIPE)
else:
print("Command not found")
This approach prevents hardcoding paths, making your code more portable across different environments or virtual setups.
This is a PATH issue - subprocess can’t find the executable. I’ve hit this before when calling command-line tools from Python. Subprocess doesn’t always inherit your terminal’s PATH, especially if jira-agile-metrics got installed in a user-specific spot or virtual environment. Use the full path instead of just the command name. Run which jira-agile-metrics in your terminal to get the location, then use that complete path in your subprocess call. You could also pass the PATH environment variable to subprocess with the env parameter, but the absolute path is more reliable.