0

For a school project I need to know how to run a Python script from another one that's also written in Python (for the raspberry pi).

martineau
  • 119,623
  • 25
  • 170
  • 301
  • 3
    `subprocess.call([sys.executable, 'otherscript.py', 'arg1', 'arg2'])` – tdelaney Jan 21 '17 at 16:18
  • I've just tried it but it does not work – vassili_veronesi Jan 21 '17 at 16:24
  • 1
    vassili_veronesi: In that case, please [edit] your answer and add code showing what you tried that didn't work (and information on the errors encountered running it). – martineau Jan 21 '17 at 17:46
  • If the other script is in the same directory as the first one, you can simply `import` it as a module. For example, if the second script's filename was `second.py`, you would need to use `import second`. – martineau Jan 21 '17 at 18:15
  • You might want to check this thread http://stackoverflow.com/questions/7974849/how-can-i-make-one-python-file-run-another – pmuntima Jan 22 '17 at 05:26

0 Answers0