kcoley / gltf2usd

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

Error python gltf2usd.py #185

Open ZeroSOFAD opened 4 years ago

ZeroSOFAD commented 4 years ago

I get an error

------ERROR-----

C:\OpenServer\domains\3d\gltf2usd-master\Source>python gltf2usd.py -h Traceback (most recent call last): File "gltf2usd.py", line 21, in from _gltf2usd.gltf2loader import GLTF2Loader, PrimitiveMode, TextureWrap, MinFilter, MagFilter File "C:\OpenServer\domains\3d\gltf2usd-master\Source_gltf2usd\gltf2loader.py", line 9, in import gltf2usdUtils ModuleNotFoundError: No module named 'gltf2usdUtils'

------ERROR-----

And the same error when

C:\OpenServer\domains\3d\gltf2usd-master\Source>python gltf2usd.py -g c:\OpenServer\domains\3d\scale_box.gltf -o c:\OpenServer\domains\3d\scale_box.usda

felipe-dap commented 3 years ago

Cheers ZeroSOFAD. This is likely due to Python versions, I suppose. I am not a mantainer for this repo but I ran into this issue today and managed to fix it with some simple changes. Let me know if help on this is still relevant for you.

rohitmorph commented 3 years ago

Hey felipe-dap, could you please help me with this issue. I am having the same exact problem but I'm on Ubuntu 20.04 and Python version is 3.8.5.

felipe-dap commented 3 years ago

Hey, rohitmorph! You might be having a problem with file referencings. Try something like this: gltf2/init.py // fix module importing with _gtfl2usd

from _gltf2usd.gltf2.Skin import Skin from _gltf2usd.gltf2.Node import Node from _gltf2usd.gltf2.Animation import Animation from _gltf2usd.gltf2.Scene import Scene from _gltf2usd.gltf2.Mesh import Mesh from _gltf2usd.gltf2.Material import Material

gtflLoader.py // fix module importing with _gtfl2usd import _gltf2usd.gltf2usdUtils from _gltf2usd.gltf2 import Skin, Node, Animation, Scene, Mesh, Material, GLTFImage, Asset

usdMaterial.py // fix module importing with _gtfl2usd from _gltf2usd.gltf2 import Material, GLTFImage from _gltf2usd.gltf2usdUtils import GLTF2USDUtils from _gltf2usd.gltf2.Material import AlphaMode from _gltf2usd.gltf2loader import TextureWrap

---- BESIDES THAT, you will have to change another few things: Class Node from gtfl2 Line 11 -> unicode has to be changed to str for Python 3. Line 11 -> becomes like this if isinstance(self._name, str):

Class Skin from gtfl2 Remove import Set from sets, as it is built-in for Python 3. change Set to set on the file, whenever it has called. If I remember it correctly, it was called just once. Line 24 becomes like this: root_joints = set()

gltf2usd.py On line 396 I had to force indices length/3 to return an integer as follows. num_faces = int(len(indices)/3)

Have a look at issues 191 and let me know if you need more help on this. Lastly, my needs did not covered Animations and Images so you might need to change unicode and set imports there as well. Cheers.

rohitmorph commented 3 years ago

Hey felipe-dap,

I really have no clue how to thank you for this. You are amazing my friend. Wish I could buy you a beer!

Followed your suggestion and it worked perfectly well. I had one other similar error. I'm mentioning it here just in case other people have the same issue.

Class GLTFImage from gtfl2 Line 53 -> unicode has to be changed to str for Python 3. Line 53 -> becomes like this if isinstance(self._name, str):

Thank you very very much felipe-dap! Cheers & have a great day!

felipe-dap commented 3 years ago

Good! Glad it worked! Cheers!

methot-ilya-3ds commented 2 years ago

I tried to make these changes as well, but I am now getting this error: ModuleNotFoundError: No module named 'gltf2'

Not sure what I did wrong?

felipe-dap commented 2 years ago

Hello @methot-ilya-3ds Been a while that I did this so I don't have it fresh in my mind. I remember it was kind tricky. So let's try to make it work. =) What python version are you using? Can you post the whole error here? Are you using a virtual environment?

methot-ilya-3ds commented 2 years ago

@felipe-dap Hi Felipe, I actually ended up completely re-copying the project and starting from scratch and somewhere along the line I figured it out.

There are a couple of lines in the repo that are not updated for the latest USD package, such as animation support, but otherwise I was able to get the conversion working!

felipe-dap commented 2 years ago

@methot-ilya-3ds Good! Happy coding! Cheers.