It seems that PYTHONPATH environment variable is removed from TD environment after start. This is causing me problems especially when running Engine COMP. Since this environment variable is removed from TD environment, Engine COMP launched from this environment doesn’t have access to PYTHONPATH and therefore can’t find python modules.
I think this should be considered as bug (as all other environment variables seem to be preserved). Also when comparing this behavior with other software (like Houdini for example), they doesn’t seem have this problem (PYTHONPATH is preserved).
I’ll log this for developers to look into it and get back to you.
However, I’m not 100% sure of the use case here, if you care to elaborate.
As far as I understand the PYTHONPATH env variable would be set on your end to something like C:\Python38 or something, right ?
So, looking for modules in here from TD wouldn’t make much sense, since the Python install of TD itself is in TD’s install folder. At least, the default behaviour. This is likely why PYTHONPATH is “silenced” but I need to confirm this bit…
Are you trying to add extra modules using another Python install? if so, the process wouldn’t be too different from the Anaconda integration. You need to add your Python site-packages and eventually binaries to the search PATH of your project.
Yes, I am adding extra python modules to be used within TD. It works for main process, but since PYTHONPATH is not preserved there, it doesn’t work for child processes (most commonly Engine COMP).
I have read your Anaconda tutorial (nicely written by the way), but setting paths from from within TD (by working with python’s sys.path & os.environt["path"]) isn’t ideal in more complex pipelines - these are driven heavily using environment variables (for example see Rez - which is used for complex pipelines by many big vfx studios).
Hi - sorry you’ve run into this. @JetXS isn’t quite right about PYTHONPATH in TouchDesigner - we do use it to locate Python modules (as long as they match TouchDesigner’s Python version) - the documentation is here.
The bug which caused PYTHONPATH to be lost in the Engine COMP is fixed in the next release.