Issue with subprocess.Popen giving [WinError 5] Access is denied


I followed Matthew Ragans tutorial on process management found here:

Ive setup my network to launch a script at start and whenever it attempts to launch this script it fails with the WinError 5 code. I’ve tried everything I can think of from making sure TD is ran as an admin and even making sure the python.exe file does the same. It always give the permission denied on the following line:

bm_process = subprocess.Popen([python_exe, button_monitor_script], shell=False)

I’m currently using python 3.8.6 with TD Build 2020.42700 on windows 10. I can run the referenced script outside of TD directly in command prompt or with an IDE with no issues at all.

Hoping I’m just missing something simple.

Here is the more complete code:

import os
import sys
import subprocess

button_monitor_script = '{}/scripts/'.format(project.folder)

python_exe = os.path.dirname(sys.executable)

# call our script with subprocess
bm_process = subprocess.Popen([python_exe, button_monitor_script], shell=False)
bm_id =

process_manager = {
	"bm_process" : bm_process,
	"bm_id"      : bm_id,

parent().store('process_manager', process_manager)

print('External Script Launched')

And here is the full error:

Traceback (most recent call last):
  File "/project1/execute1", line 9, in onStart
td.Error: File "/project1/external_python_start", line 21
  File "C:\Program Files\Derivative\TouchDesigner\bin\lib\", line 775, in __init__
    restore_signals, start_new_session)
  File "C:\Program Files\Derivative\TouchDesigner\bin\lib\", line 1178, in _execute_child
PermissionError: [WinError 5] Access is denied
Results of run operation resulted in exception.

I figured it out. I was only calling the python install directory but did not include the python.exe app name. After adding that it works now.