CoXier
CoXier

Reputation: 2663

Dart execute command always `No such file or directory`

I want to execute a command python /Users/xx/mail_utils.py in Dart. As you see, I have used absolute python file path.

When I execute above command in terminal, it works. However when I call it in Dart.

Process.run('python /Users/xx/mail_utils.py',['xx']).then((ProcessResult results) {
  print(results.stdout);
});

Unhandled exception:

ProcessException: No such file or directory

Command: python /Users/xx/mail_utils.py xx

What's wrong ?

Upvotes: 2

Views: 866

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657048

You probably want

Process.run('python', ['/Users/xx/mail_utils.py','xx']).then((ProcessResult results) {
  print(results.stdout);
});

The first parameter should only be the executable. Parameters go into the array that is passed as second parameter.

Upvotes: 5

Related Questions