FIXED: Problem with PYTHONPATH env variable

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).

Hey @monty_python

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.

We’ll get back to you,


@JetXS thanks for reply.

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.

@bangnoise thank you very much for fixing this, it is going to save me from great deal of trouble :slight_smile:

1 Like

@bangnoise I have just tested this in the latest stable and it works great - thanks once again :+1: