Reputation: 614
I am trying to use subprocess to call my current script as follows:
import subprocess as sb
current_path = os.path.realpath(__file__)
sb.call(['python3', current_path])
However, I am ending up in a :
FileNotFoundError: [WinError 2] The system cannot find the file specified
What could I be doing wrong?
Upvotes: 1
Views: 54
Reputation: 106553
python3.exe
does not exist in any of the paths in your PATH
environment variable. Use an absolute path to specify python3.exe
instead, or use the shell=True
argument:
sb.call(['python3', current_path], shell=True)
Upvotes: 1