FIXED: PYTHONPATH Env variable gets lost when opening recent project

Hey everyone,

I want to use the PYTHONPATH Environment Variable to locate a few Python Modules. This works fine when starting Touchdesigner, but whenever I use the File > Open Recent Dialog, Touchdesigner cannot locate the modules anymore. I assume this is a bug, or am I doing something wrong?

Maybe this is connected to this post: FIXED: Problem with PYTHONPATH env variable in any way?

Best regards,

Hey @fynnkonig

Are you starting the TouchDesigner process from a .bat file or something ? And setting PYTHONPATH at that point for it to be passed to TouchDesigner ?

I believe I was able to reproduce and it behaves like this just with PYTHONPATH specifically as far as I could tell.

Using another variable like “CONDA_ENV” worked fine.

What happens is that when you use Open Recent Dialog, a new process of TouchDesigner is being started and the previous one is killed. The env variable (PYTHONPATH) doesn’t seem to be passed from one process to the other.

I will log this as a bug, it seems quite similar to that other issue you linked.

Are they a reason why you are not using the preferences dialog setting to set a path ?

You could also follow the anaconda tutorial here and grab the Execute DAT script / snippet on this page. This should allow you to work with those packages across projects as long as you have the Execute DAT around.


Hey @JetXS
Thanks so much for your response, its insane how fast you guys answer!

I´m not starting Touchdesigner from a .bat file. I created a powershell-script to set the PYTHONPATH Environment-variable and then just start touchdesigner from a shortcut to the .exe or by double clicking the project file, which does the same I guess and just pass the project as additional argument?

The anaconda tutorial looks really interesting, but might not exactly meet my needs…
I created a whole lot of python code to run inside touchdesigner, including data-classes to pass data from one tox to another fluently. Therefore I want to import some scripts that need to be available on startup (as I use the startup execute to initialize the patch). Is there a way to make sure that the anaconda setup is run before everything else when you have multiple execute dats all over the patch?

I dont use the preferences dialog as I´m moving fast between different maschines and projects and like the idea of having a deployment-script, which will do the whole setup automatically. I even thought about changing the config-file for the preferences dialog, but as the path is different on MacOS and Windows and I might overwrite something I didnt mean to, I went with setting environment-variables. However, especially for project switching (maybe not for production deployments though) I like the anaconda idea and will think about how I can integrate that in my workflow.

Best regards and thanks again,

Hey @fynnkonig

Thanks for all the (great!) details and info.

Yeah so if you run from a powershell script it should be similar to a .bat.

What you want to do for the time being is avoid that Open Recent menu. The issue is logged and will be patched.

If you use multiple Execute DATs, it will be difficult to know which one is called first, indeed.
What I’d do in that case is use only one to setup all your python environment and trigger some “PostInit scripts” at the very end of this callback, from an Extension being called or a Text DAT being executed with run().


1 Like

This will be fixed in the next official build we post, 2022.33320+.

Awesome! Thank you so much for the great help! Have a nice week!

1 Like