I’m quite a newby in the TD world. I’m trying to import some external python modules from a 3.5 anaconda environment on mac 10.14.5 running TD build 2019.17550.
Good news first:
I could manage to execute my scripts as a separate python thread. yay
Bad news:
when I open my TD project and I want to run my script for the first time TD promts the attached popup error.
As soon as I click OK and run the script again the popup doesn’t occur anymore and the python code executes properly.
The popup occurs as soon as I import the libraries by executing the following script:
import fnmatch
import os
import numpy as np
from sklearn.manifold import TSNE
import json
import threading
import sys
import librosa
My Python 64-Bit Module Path is:
“/anaconda3/envs/td35/lib/python3.5/site-packages”
… so there are no spaces in the path name or anything else problematic I suppose.
In addition to that I renamed thy numpy module folder shipped with TD to under “/Applications/TouchDesigner099.app/Contents/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy” to “numpy_old” and used the one from my anaconda environment because it didn’t work with the sklearn library.
Do you have any ideas what this popup may come from?
It’s a bit strange to me because my script works properly in TD. The popup only occurs at the first iteration. After I press OK it works properly…
EDIT: I attached a simple toe file causing the popup.
I took a quick look at your toe file but didn’t install any additional libraries. If I’m understanding you correctly, you get the popup error when you click the Launch Process button in your sample file.
When I tried it, I left out this line and did not get any popup errors. Is that true for you?
from sklearn.manifold import TSNE
If that is the case, if you leave the import line above, but comment out
Do you still get the popup error? The popup error indicates to me that something is trying to launch another TouchDesigner process, and I’m wondering if it is the external module initializing and possibly trying to launch another python process by launching another instance of the parent process. -B appears to be a python option for “Don’t write .py[co] files on import”.
I’m getting a similar error, but with the message “…unknown argument: -c was given to TouchDesigner as a command argument…” instead of -B like the original post.
This is on experimental 2019.30550, when trying to use the multiprocessing.Process.Process() function. POpen and manually specifying a python.exe works just fine, as highlighted in Matthew Ragan’s subprocessing post.
I agree with your conclusion that starting a subprocess is somehow picking touchdesigner.exe instead of python.exe, so any subprocess initialization simply fails. If you keep a reference to the process handler, you can see that it executes but immediately terminates, even if you have an infinite loop in the function passed to the subprocess.