Import mediapipe worked in Terminal, but failed in TD

Hi, I was trying to import mediapipe in TouchDesigner. My python version is 3.11.

As you can see from below, I can import it successfully in my terminal:

However, I failed in TouchDesigner and got this error:
python >>> import mediapipe
ImportError: cannot import name ‘resource_util’ from ‘mediapipe.python._framework_bindings’ (unknown location)

Anybody came across the same issue? Any solution or idea?

Thanks!

Hey @Naive_Cross

Did you follow any of the instructions here: Category:Python - Derivative

Thanks,
Michel

Hi Michel,

I tried the instruction you shared. It seems that mediapipe is not found in brew:
Warning: No available formula with the name “mediapipe”. Did you mean media-info?

Also tried use pip install in python3.9 (instead of 3.11). However, when importing mediapipe in TD, this error raised:
mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’

Do you have any idea how to fix this? (Is it about my TD version? It’s non-comercial 64-bit 2022.29850)

Thanks!

Is your Mac a Mac Intel or Mac M1 ?

If so you need to make sure that your pipeline is using only one architecture.

If you are on an M1:

  • TD Build is the ARM / M1 Build, use the latest version. 2022.29850 is old already.
  • Python installed through brew needs to be the ARM version, version 3.9.5, since that’s the version that match TouchDesigner
  • Mediapipe needs to be installed in the Python ARM ecosystem

With all that, you should be able to import in TouchDesigner.

This is documented at the previously shared link.

Best,
Michel

Hi. Have the same issue. Mac M1 Pro the last version of TD. Reinstalled Python by instruction via homebrew.

Please, any help!!! Thanks

can you please share you scripts and other ? how do you add the homebrew environment to TouchDesigner ?

I have added the path in Preferences:

And I created the start script as well:

You are trying to sideload a Python 3.11 environment when TouchDesigner’s version is 3.9.5.

This is likely what’s causing the issue.

See in our doc:

To use a specific version, such as matching TouchDesigner’s Python 3.9, add @3.9 after python .

You don’t need to use the preferences dialog if you use the start script.

Especially if you toggle in the preferences “Search External Python Path Last”.

Can you go in the textport and call

import sys
sys.path

and share what’s in your path ?

Got it! The problem was with the python version. I didn’t realise it’s so important in exact this case. Thanks a lot.

1 Like