MasayoMusic
MasayoMusic

Reputation: 614

Subprocess doesn't find my file (file not found error)

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

Answers (1)

blhsing
blhsing

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

Related Questions