Td pip - 2020-08-07 23:19


Link to main site

1 Like

oh, this is nice!
Question: when using “Import_Module()” how do I perform a import qrcode as qr ?


Import_Module is the equivilant of import as, so you just write qr = op(‘pip’).Import_Module( ‘qrcode’ ) and then use qr as if you used the import as statement.

thx @alphamoonbase. That is pretty elegant solution.

Thanks, glad you like it. The question of how to get PIP to work with TD just came up to often so i had to take a shot :slight_smile:

A little update: I was under the assumption that the names in pip and the module names are the same, which is in fact not the case.
The Import_Module method offers now an optionaö pip_name argument to define the package name seperate from the module name.

1 Like

I updated the PIP-Version. (I need to find a way to do that dynamicly…) and now default install setuptools with the first init routine !

Hey All,

I’m having a bit of trouble here. After starting and saving a new .toe, I dropped TD_PIP.tox into that same folder, then drag the TD_PIP.tox onto my network editor, which creates the TD_PIP base.

I understand that TD_PIP is best used by scripting the module imports (op(‘td_pip’).InstallPackage( package_name )), but I can’t even get it to work ‘manually’ by typing the name into “package” param and clicking the “install” pulse button.

For example, I am using “pyglet” package.

The “check” pulse button works, and I receive “package not installed.” But when i click “install” pulse button, nothing happens. I looked at the log inside of TD_PIP and it simply just says “failed installing package.” I tried 3 other packages, no dice.

What OS are you o?

Mac OS 12.2.1

TD Pip is not supported on MacOS for the forseeable future.

This is just excellent. Great job, and thanks for sharing with us.

1 Like

Hi! I’m new to external libaries in Touchdesigner. I’ve tried using your .tox file and although it does create a lib folder, I can’t seem to get it to download packages. I’ve tried using your example of
qrcode = op(‘td_pip’).Import_Module(“qrcode”)

I open a text dat and cut and paste that in then run script and then I check the lib folder but nothing new is there. I"ve tried putting qrcode into the packge parameter on the Custom page within the tox but that doesn’t seem to do anything either. It looks like my powershell on my computer opens momentarily but it closes before I can see what’s happening. When I open powershell manually it doesn’t show any activity.

I’m trying to use this repo:

I tried opening a text DAT and running
op(‘td_pip’).InstallPackage( petal-api-getting-started )
to which I got an error saying petal was not defined.
So I tried
petal = op(‘td_pip’).Import_Module(“petal-api-getting-started”)
and received the following error:
AttributeError: ‘NoneType’ object has no attribute ‘Import_Module’

Could you point me in the right direction? Much appreciated. I’d like to use your tool as it looks like such a good solution!

Kindest Regards,

E. Spencer Lewis

Heyho. Do you maybe have a .toe file for me to check?
Also, which OS are you using? Which TD Version are you rinning?
TD_PIP is currently not supported on MacOS.
Also, how does your libFolder look like?

Hi! When installing pip the installation fails, do you have any ideas why that could be?

Which OS are you on? How does it fail? Any more info?

Im running windows 10 on amd64, it throws an exception during installation of pip. Sometimes it works sometimes it doesn’t, I would love for it to be consistent

after looking a bit more into it, why don’t you just use the ensurepip module instead of using the wheels inside it’s source files?

Can you please set “TOUCH_TEXT_CONSOLE” env variable to 1 and check what the output to narrow it down? Did not have any issues with that so need some more hints to “make it consistent”.
Also, please post the exception…

Regarding using ensurepip: There were reasons for not using it, but not sure right now, can revisit it.

EDIT: Did a quick test: The problem is that ensurepip opens a subprocess which in TD is a new TD-Instance instead of the python interprete, which results in an error.
Also, the unpacking is basicly 1 to 1 what the esnurePIP is doing.

@alphamoonbase - Thank you for your amazing work on this asset!

I have figured out how to make your asset compatible with Mac OS (I’m running TD 2023.11600 on Mac OS Sonoma14.4.1).

Per, you can use app.pythonExecutable to access directly the path to the TD python instance.

On line 43 of /td_pip/extPip (an Execute DAT), replace:

return f"{app.binFolder}/python"


return f"{app.pythonExecutable}"

I think the same would work at line 47 for win32 architectures.