0

I'm trying to execute a Python command within my Scala application. I've seen multiple SO questions showing how to do this, and it works, but my second command doesnt seem to do anything. In the code below, from src.main import run_beta; executes but run_beta() does not.

When I run it straight in the command line: python -c 'from src.main import run_beta; run_beta()', it works fine. Any ideas what I'm doing wrong?

val cli_command = Seq(
  "python"
  ,"-c"
  ,"'from src.main import run_beta; run_beta()'"
)

println(s"CLI command is: $cli_command")

val cli_logger = ProcessLogger(
  (o: String) => println("CLI_STDOUT: " + o),
  (e: String) => println("CLI_STDERR " + e))

cli_command ! cli_logger
2
  • 2
    While you're debugging, remove the single-quote marks '. I don't think they serve any purpose when invoked without the shell. Commented Mar 26, 2021 at 20:12
  • Thanks @jwvh - Removing the single quotes solved the error! Commented Mar 26, 2021 at 20:48

1 Answer 1

1

As per jwvh's comment, removing the single quotes around 'from src.main import run_beta; run_beta()' solved the problem.

Instead I ran: from src.main import run_beta; run_beta() and it worked as expected.

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

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.