Login | Register 

Installing Python Modules to a TouchDesigner-specific Path

Helpful techniques for working with TouchDesigner. Answers only, no questions.

Installing Python Modules to a TouchDesigner-specific Path

Postby doctorhandshake » Mon Nov 20, 2017 11:42 am

Got a question the other day about how to install packages to other than the default Python site-packages folder* — I have to reconstruct this every time I do it but a really simple method:

Code: Select all
pip install --target=/path/to/your/packages/directory/for/TD package_to_install

... and then just point Touch to that path for your Python 64-bit module search path in the prefs. It's probably a good idea to have a dependencies folder in the same directory as each project (see below).

* this is Good Practice - generally it's a Bad Idea to install anything to your system Python as then you have no idea what your dependencies are when you go to move a project to another system. Also updates can break old projects.

I've done a version of this with virtualenv and am trying to figure out how I did that (there's a flag for virtualenv that tells it to install dependencies in a specific directory, I think).

Also this should be possible with pipenv too. Both of those options allow you to 'freeze' an environment and make a requirements.txt file you can check in to a repo so users can pull down the right version of all your requirements fresh without your checking all your requirements into the repo, which is bloated and not a good idea.

I'll follow up if I remember how I did that.
Noah Norman

codename: massapequa
User avatar
Posts: 141
Joined: Wed Aug 17, 2011 6:31 pm
Location: Brooklyn, NY

Re: Installing Python Modules to a TouchDesigner-specific Pa

Postby ishelanskey » Mon Jan 15, 2018 4:03 pm

I love this technique for modules I use for every project. All of my servers get useful modules installed right in the TD path. It makes it so a lot of my reusable toxes function across projects.

Any time I have project independent modules I create a folder in my project folder called "external". I add python modules in much the same way but targeting "external".

Then in a startup script in TD I add:
Code: Select all
import sys
import <ExternalModuleHere>

You can then import the module where ever you need in the network.

I've never used virtualenv or pipeenv but I would be interested to see how you do that.
Posts: 30
Joined: Fri Jan 10, 2014 12:29 pm

Return to Techniques

Who is online

Users browsing this forum: No registered users and 2 guests