title: How can I open another Python file using Python Subprocess?
body: <p>I have a Python file, which I want to open, keep open for 5 seconds, and then close it, and then repeat. I am using Python Subprocess for this, using the following code:</p>
  <pre><code>import subprocess
  import time
  import sys
  
  p = subprocess.Popen(&quot;pagekite.py&quot;)
  time.sleep(4)
  p.terminate()
  </code></pre>
  <p>However, it gives me the following error:</p>
  <pre><code>Traceback (most recent call last):
  File &quot;C:/Users/ozark/Desktop/Savir/Programming/Choonka/closetry.py&quot;, line 5, in &lt;module&gt;
  p = subprocess.Popen(&quot;pagekite.py&quot;)
  File &quot;C:\Users\ozark\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py&quot;, line 854, in 
  __init__
  self._execute_child(args, executable, preexec_fn, close_fds,
  File &quot;C:\Users\ozark\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py&quot;, line 1307, in 
  _execute_child
  hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
  OSError: [WinError 193] %1 is not a valid Win32 application
  </code></pre>
  <p>It seems only executables can be opened using this method? Then how do I do the same thing for a Python file? Any help will be appreciated. Thanks in advance.</p>
  <p>MODIFICATIONS: I am now using subprocess.call('start pagekite.py', shell=True). How do I terminate this? Thanks.</p>