Force TouchDesigner to use a specific python version

Hi all,
I’m running Windows10.

For my project I have to use Python 3.10 with tensorflow-directml, torchvision and other deep learning tools.

here is a link to one of the many guides about my project: link to derivative community post

But even by following the reported guide, i found out that the 2023 touchdesigner version (that is the last compatible one for my purpose) has python 3.11 installed by default.
Even if I link the path to the python 3.10 version in preferences, touchdesigner still uses the 3.11
I also create the system variables PYTHONHOME and PYTHONPATH

To confirm the error, if I put in a text DAT:

import sys
print(sys.version)
print(sys.path)

TD shows me in the Textport:

['C:\\Program Files\\Derivative\\TouchDesigner\\bin', 'C:\\Program Files\\Derivative\\TouchDesigner\\bin\\python311.zip', 'C:\\Program Files\\Derivative\\TouchDesigner\\bin\\Lib', 'C:\\Program Files\\Derivative\\TouchDesigner\\bin\\DLLs', 'C:\\Program Files\\Derivative\\TouchDesigner\\bin', 'C:\\Program Files\\Derivative\\TouchDesigner\\bin\\Lib\\site-packages', 'C:/Users/smanie/AppData/Local/Programs/Python/Python310', 'C:\\Users\\smanie\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages']
python >>>

So it see the two python versions, but maybe the 3.11 is the preferred one, because TD doesn’t see al my site-packages installed in 3.10 python version (for ex: torchvision, tensorflow-directml).

Help me please T__T

I’m a beginner… I was thinking to manually change the python.exe, python311.dll that are in the folder TouchDesigner/bin but I don’t know if this can work.

NB: a strange thing is that the file C:\Program Files\Derivative\TouchDesigner\bin\python311.zip that TD shows me in the Textport doesn’t exists! even if I perform a clean TD installation

TouchDesigner ship with Python 3.11 and it is required for it to run. You should not play with the python files to downgrade to a lower python version or TouchDesigner will likely not run or become unstable.

What we recommend is for third party libraries or side loaded environment to always match TouchDesigner’s version.

Unless I’m missing something - I didn’t go through the video, nowhere in that tutorial it states that you should add Python 310 to TouchDesigner’s search path, it mentions the system path, in the system environment variables.

Best,
Michel

1 Like

Yeah, most of the libraries are only compliant for python 3.10 and so I have to find a way to make TD works with Python 3.10… but even by adding the python 3.10 path to touchdesigner, it seems that TD doesn’t see the installed libraries for python 3.10

In TD Preferences I mannually added the path to the Python 3.10 folder in the “Python 64-bit Module Path” and biffed:
“Add Externally Installed Python Site-Packages to Search Path”
“Add Python User Site-Packages to Search Path”
“Search External Python Path Last”

Hi,

I skimmed through both videos. The one you linked and the one mentioned toward the end.

Again, unless I missed it, and you should point me to it, none of those videos mention adding python 3.10 to TouchDesigner’s path: the first one mention making sure libs are in your system environment path, which is not TouchDesigner’s path.

Best,
Michel

1 Like

JetXS you are an angel!

You are right; I added python 3.10 to TouchDesigner’s path, not following the tutorial, because the first time I tried to run the streamdiffusion TOX, it crashed after 2 seconds.
In the log, I saw the error:

ModuleNotFoundError: No module named ‘torchvision’

Although torchvision is correctly installed*, I thought it was one of the first libraries that the TOX looked for and couldn’t find. Thus, this error originates because TD couldn’t find Python 3.10.

*torchvision is installed in Python 3.10 folder with all the other necessary libraries.

If you think that I have to “reset” this settings I will do it:

In TD Preferences I manually added the path to the Python 3.10 folder in the “Python 64-bit Module Path” and checked:
“Add Externally Installed Python Site-Packages to Search Path”
“Add Python User Site-Packages to Search Path”
“Search External Python Path Last”

I apologize for my lack of clarity:
After the error that TD gives me, I changed the system variables by adding the path to python 3.10 and I have also set PYTHONHOME and PYTHONPATH…
I have also added python 3.10 to bash… but it doesn’t work, giving me the error that it can’t find torchvision (which I repeat is already installed).

So the modification I made in

  1. TD preferences;
  2. the system environment variables;

were done after the error:

ModuleNotFoundError: No module named ‘torchvision’

However, these changes did not solve the problem.

Please let me know if you need any other information about my configuration, and thank you so much for your time and assistance :smiley:

Kind regards
Valerio

You will need to get additional assistance from the developer of the component. This is not an official TouchDesigner tool and I do not have the required files to test further.

Best,
Michel

Ah ok, I thank you anyway for the help, but most of all for the time spent, Michael.

I’ll try to reach out to the tool’s developers, though I doubt they will reply.

Bye
Valerio