pymesh icon indicating copy to clipboard operation
pymesh copied to clipboard

Failed to load OBJ file.

Open QuantumLiu opened this issue 7 years ago • 1 comments

mesh = obj.Obj('dapeng.obj') Traceback (most recent call last): File "/home/quantumliu/anaconda3/lib/python3.5/site-packages/pymesh/obj.py", line 52, in __read elif line.lstrip().startswith("vn"): TypeError: startswith first arg must be bytes or a tuple of bytes, not str

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/home/quantumliu/anaconda3/lib/python3.5/site-packages/pymesh/obj.py", line 30, in init data = Obj.__load(fh) File "/home/quantumliu/anaconda3/lib/python3.5/site-packages/pymesh/obj.py", line 39, in __load return numpy.fromiter(Obj.__read(fh), dtype=Obj.obj_dtype) File "/home/quantumliu/anaconda3/lib/python3.5/site-packages/pymesh/obj.py", line 73, in __read raise RuntimeError("Failed to load OBJ file.") RuntimeError: Failed to load OBJ file.

QuantumLiu avatar Jan 29 '18 07:01 QuantumLiu

So I think I figured out the issue. When you open the file with the "rb" parameter, future methods need to use byte literals instead of strings. So change that in the __read(fh) method in obj.py. In other words:

elif line.lstrip().startswith("vn"):

becomes

elif line.lstrip().startswith(b"vn"):

That fixed it for me.

rweerasi avatar May 08 '19 21:05 rweerasi