kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
263 stars 39 forks source link

pxr problem #155

Closed EtienneHeyman closed 5 years ago

EtienneHeyman commented 5 years ago

Hi,

I'm a beginner in this kind of manipulation. I copied the USD folder in my pythonpath. I meet a problem I can't resolve :

macbook-pro-de-etienne:Source etienneheyman$ python gltf2usd.py -h Traceback (most recent call last): File "gltf2usd.py", line 18, in from pxr import Usd, UsdGeom, Sdf, UsdShade, Gf, UsdSkel, Vt, Ar, UsdUtils ImportError: No module named pxr

I have this problem of pxr with all commands concerning python gltf2usd.py I think I have done something wrong. May you help me ?

Thanks in advance.

Etienne Heyman

EtienneHeyman commented 5 years ago

In reality I didn't put the USD in the right folder. I put it in the pythonpath but when I run python gltf2usd.py -h ; python crash...

EtienneHeyman commented 5 years ago

*the USD folder

EtienneHeyman commented 5 years ago

I found the solution.

anthonyjames90 commented 5 years ago

I'm having the same issue - could you share how you solved it please? :-)

Traceback (most recent call last): File "gltf2usd.py", line 18, in from pxr import Usd, UsdGeom, Sdf, UsdShade, Gf, UsdSkel, Vt, Ar, UsdUtils ImportError: No module named pxr

yspark90 commented 5 years ago

@anthonyjames90 You need to set the correct Python path to the imported libraries in your terminal (shell) session:

export PATH=$PATH:<PATH_TO_USDPYTHON>/USD
export PYTHONPATH=$PYTHONPATH:<PATH_TO_USDPYTHON>/USD

For example:

export PYTHONPATH="/Users/username/Projects/Pixar/BUILD/USD/lib/python:$PYTHONPATH"
yspark90 commented 5 years ago

You can also set your .bashrc_profile to this.

anthonyjames90 commented 5 years ago

Thanks for the reply - I'd installed USD using the inbuilt script and in the readme file it told me to:

"To start using USD in Python, set your PATH and PYTHONPATH variables as follows (replace <PATH_TO_USDPYTHON> with the path to this USDPython folder):

export PATH=$PATH:<PATH_TO_USDPYTHON>/USD
export PYTHONPATH=$PYTHONPATH:<PATH_TO_USDPYTHON>/USD

You should then be able to easily inspect the content of any text or binary .usd file or a .usdz archive usding usdcat, e.g.:

usdcat samples/assets/island.usdz"

I did that, and I can use "usdcat" as it describes.

My .bash_profile is:

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH

export PATH=$PATH:/opt/local/USD/bin
export PYTHONPATH=$PYTHONPATH:/opt/local/USD/lib/python

and my .bashrc_profile is now:

export PATH=$PATH:/opt/local/USD/bin
export PYTHONPATH=$PYTHONPATH:/opt/local/USD/lib/python

I also tried what you suggested in the shell 'runtime' after launching gltf2usd.py with the Python launcher and this is the output:

MacBook-Pro:Source anthonyjames$ export PYTHONPATH=$PYTHONPATH:/opt/local/USD/lib/python
MacBook-Pro:Source anthonyjames$ sudo python gltf2usd.py -g /Users/anthonyjames/Dropbox/output/TestColladaFile1.gltf -o /Users/anthonyjames/Dropbox/output/test.usdz
Traceback (most recent call last):
  File "gltf2usd.py", line 18, in <module>
    from pxr import Usd, UsdGeom, Sdf, UsdShade, Gf, UsdSkel, Vt, Ar, UsdUtils
ImportError: No module named pxr
MacBook-Pro:Source anthonyjames$ 

Sorry if I'm being stupid or have missed something obvious, but thank you for your help!

I think I'm pointing to the right location for the USD data:

MacBook-Pro:Source anthonyjames$ cd /opt/local/
MacBook-Pro:local anthonyjames$ ls
USD
MacBook-Pro:local anthonyjames$ cd USD
MacBook-Pro:USD anthonyjames$ ls
bin     cmake       lib     pxrConfig.cmake src
build       include     plugin      share
MacBook-Pro:USD anthonyjames$ 
oguzhancevik commented 4 years ago

I found the solution.

What is the solution?

hellovarun commented 4 years ago

I found the solution.

what is it, I can you help?

hellovarun commented 4 years ago

@anthonyjames90 You need to set the correct Python path to the imported libraries in your terminal (shell) session:

export PATH=$PATH:<PATH_TO_USDPYTHON>/USD
export PYTHONPATH=$PYTHONPATH:<PATH_TO_USDPYTHON>/USD

For example:

export PYTHONPATH="/Users/username/Projects/Pixar/BUILD/USD/lib/python:$PYTHONPATH"

@yspark90 Hello! Greetings from a designer trying code I have added paths in my terminal under nano .bash_profile but doesn't seem to be working

export PATH="$PATH:/usr/local/USD/bin/" export PYTHONPATH="$PYTHONPATH:/usr/local/USD/lib/python"

Can someone help, if I'm missing something here and USD folder exits in my directory and I'm able to run the export path command directly before running the gltf2usd.py script but its temporary solution and I have to keep repeating at every executing script.