Calling a python 2.7 script with subprocess Popen

Hey all,
I have a little python (2.7) script to upload a video “testupload.py”

I am trying to call it from touchdesigner using subprocess pOpen like so

import subprocess directory = project.folder script = directory+"/testupload.py" cmd = 'C:/Python27/python.exe "{0}"'.format(script) popenResult = mod.subprocess.Popen(cmd, cwd=directory)

It doesn’t work, the file doesn’t get uploaded. I get no results in popenResult.communicate, etc.

But if I type this into python running outside of touchdesigner, it works fine (once I hardcode the directory as there is no ‘project.folder’ from the python shell).

I am using the interactive textport dat shell.

Any help?

I was just fighting with Popen last night.

What finally worked for me was using double \ in my directory paths:

script = ''directory\to\the\script.py"

I think Popen also wants a list of args. I finally got what I was after this way:

[code]from subprocess import Popen

file = “E:\GitHub\Beneath\tools\robo_copy\batTest.bat”

Popen( [ file ] )[/code]

Hmm, backslashes doesn’t seem to be the problem.

So I have an external script, “testUpload.py” and it imports the requests module.

As it seems difficult to follow the script as it goes, i have it writing its output to a file, and i’m outputting a line every line that it executes. It dies as soon as I try to import the requests module in “testUpload.py”

Essentially the problem is that once i’m in the testUpload environment, it can’t access the site-packages that are installed in the OS, so maybe environment variables aren’t the same under pOpen?

Has anyone else had this problem?