6

I'm running into this issue after installing USDZ tools from Apple's website. I'm a bit rusty at Python and tried installing all the underlying packages.

I set my PYTHONPATH already using export PYTHONPATH="/Users/gt/usdpython/USD/lib/python:$PYTHONPATH"

USD git:(master) ✗ usdzconvert
Traceback (most recent call last):
  File "/Users/gt/usdpython/usdzconvert/usdzconvert", line 17, in <module>
    usdUtils.printError("failed to import pxr module. Please add path to USD Python bindings to your PYTHONPATH.")
NameError: name 'usdUtils' is not defined
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
aspdev91
  • 137
  • 2
  • 9

2 Answers2

7

Download the latest version – usdpython 0.66 from https://developer.apple.com.

You need to paste these 3 lines inside .zshrc file – you can see how to create it HERE.

export PYTHONPATH="/Users/gt/usdpython/USD/lib/python:$PYTHONPATH"
export PATH="/Users/gt/usdpython/USD:$PATH"
export PATH="/Users/gt/usdpython/usdzconvert:$PATH"

P.S.

Do not use the version of usdpython_0.63 (Feb 5, 2020) because it unfortunately causes errors.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • Thanks. I have that in my `.zshrc`, but it's still throwing the same error. My PYTONPATH: `echo $PYTHONPATH /Users/gt/usdpython/USD/lib/python:` The `PATH` includes those two strings – aspdev91 Feb 07 '20 at 22:52
  • @aspdev91, please, let me know whether it works or not. – Andy Jazz Feb 09 '20 at 13:48
  • 2
    This solved the problem for me. Also you don't have to set the path in .zshrc file. Clicking on the USD.command file exports all the required paths for that shell instance – Akshay Shinde Feb 10 '20 at 19:55
  • 3
    I ended up just using the Reality Converter GUI tool provided by Apple here https://developer.apple.com/services-account/download?path=/Applications/Reality_Converter/Reality_Converter_Beta.dmg Thanks everyone! – aspdev91 Feb 12 '20 at 14:32
  • 1
    Was having a lot of issues with this too. Downloading the 0.62 version worked for me, now I can open USD.command everything is working. Thanks! – Austin Mar 01 '20 at 19:57
  • What kind of insider information is this "0.63 is broken" ??? Andy you're a torch bearer... – Pavel Zdenek Apr 10 '20 at 09:38
  • Hi @PavelZdenek, I haven't found any insiders' info on `usdpython_0.63`, can't tell you why it's broken(( – Andy Jazz Apr 10 '20 at 10:26
  • I can't seem to get this to work. Getting the error `Error: failed to import pxr module. Please add path to USD Python bindings to your PYTHONPATH` https://imgur.com/a/uBDatMS – ChrisB Dec 22 '21 at 21:28
  • @ChrisB, try running another library (not usdpython) - and see if it works. If another library also gives any errors, then you have a problem with your command line. – Andy Jazz Dec 22 '21 at 21:38
  • 1
    @AndyJazz thanks for your suggestion. Apologies, not sure what you mean. How can I run another library? Other python scripts seem fine. I've also tried another machine, (Mac Mini), installed USD Tools from the Apple website from scratch, followed instructions and run into the exact same error as on my macbook. Also, I can `import pxr` without error if I use the python interactive shell. – ChrisB Dec 22 '21 at 21:53
  • What are your macOS and Xcode versions? – Andy Jazz Dec 22 '21 at 22:23
  • 1
    macOS is Monterey with the latest Xcode, but I've found the solution: *You need to open the terminal in Rosetta mode. Then it works.* Thanks for your offer to help! – ChrisB Dec 22 '21 at 22:28
  • For anyone looking for the different versions, you can find them here: https://developer.apple.com/download/all/?q=USD – josezenem Aug 03 '22 at 19:25
1

Run Rosetta Terminal fixes it. https://developer.apple.com/forums/thread/671459

Wayne Ohm
  • 61
  • 1