trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

[Bug] AttributeError: module 'trimesh.voxel' has no attribute 'creation'

Open trisct opened this issue 4 years ago • 5 comments

Trimesh version: 3.9.1

Hi. I discovered that trimesh reports the following error

AttributeError: module 'trimesh.voxel' has no attribute 'creation'

when trying to access the module. However, if a method from it is called, e.g.

m = trimesh.creation.box()
m.voxelized(pitch=.5)

then the module trimesh.voxel.creation can be correctly found by the program.

trisct avatar Jan 23 '21 08:01 trisct

Meet the same problem. Would like to follow this channel.

yuchenrao avatar Jan 31 '21 15:01 yuchenrao

same here. able to solve this by import creation myself

from trimesh.voxel import creation

ShunChengWu avatar May 20 '21 10:05 ShunChengWu

Hmm, that exact m.voxelized(pitch) line is called in unit tests. Do you have a full traceback? I suspect it could be a missing dep with a confusing error message?

mikedh avatar May 21 '21 05:05 mikedh

same here. able to solve this by import creation myself

from trimesh.voxel import creation

It works, thanks

MarkTech2018 avatar Jul 28 '21 12:07 MarkTech2018

Problem still present with version 3.12.6 and now in addition rtree is a missing dependency.

alexge233 avatar Jun 22 '22 15:06 alexge233

I've just bumped into this issue with version 3.15.8.

chlongv avatar Nov 17 '22 10:11 chlongv

Hey, I checked a minimal install on Python 3.10, 3.7, 3.5, 2.7 and this issue didn't occur in a simple example, does anyone have a reproducible docker snippet or full traceback including the line number where this was called from?

3.10:

mikedh@orion:~/trimesh$ docker run -it python:3.10-slim-bullseye /bin/bash
root@3d8b25c2742e:/# pip install trimesh
Collecting trimesh
  Downloading trimesh-3.16.4-py3-none-any.whl (663 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 663.9/663.9 kB 6.2 MB/s eta 0:00:00
Collecting numpy
  Downloading numpy-1.23.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.1/17.1 MB 41.9 MB/s eta 0:00:00
Installing collected packages: numpy, trimesh
Successfully installed numpy-1.23.4 trimesh-3.16.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip available: 22.2.2 -> 22.3.1
[notice] To update, run: pip install --upgrade pip
root@3d8b25c2742e:/# pythonPython 3.10.8 (main, Nov 15 2022, 21:06:05) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import trimesh
>>> m = trimesh.creation.box()
>>> m.voxelized(pitch=0.5)
<trimesh.VoxelGrid(3, 3, 3)>
>>> m.voxelized(pitch=0.5).volume
3.250000000000001

3.7:

mikedh@orion:~/trimesh$ docker run -it python:3.5-slim-bullseye /bin/bash
Unable to find image 'python:3.5-slim-bullseye' locally
docker: Error response from daemon: manifest for python:3.5-slim-bullseye not found: manifest unknown: manifest unknown.
See 'docker run --help'.
mikedh@orion:~/trimesh$ docker run -it python:3.7-slim-bullseye /bin/bash
Unable to find image 'python:3.7-slim-bullseye' locally
3.7-slim-bullseye: Pulling from library/python
a603fa5e3b41: Already exists 
b00aaacf759c: Already exists 
bfd5215df481: Pull complete 
646c640d7dca: Pull complete 
2ca40dc2918a: Pull complete 
Digest: sha256:7816ff9e4f2c31671cc7db97ea99e05a2e5fd508eaeced99e0939dbadf4f670a
Status: Downloaded newer image for python:3.7-slim-bullseye
root@3e51ac02d5f2:/# pip install trimesh
Collecting trimesh
  Downloading trimesh-3.16.4-py3-none-any.whl (663 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 663.9/663.9 KB 5.9 MB/s eta 0:00:00
Collecting numpy
  Downloading numpy-1.21.6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.7/15.7 MB 10.9 MB/s eta 0:00:00
Installing collected packages: numpy, trimesh
Successfully installed numpy-1.21.6 trimesh-3.16.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
root@3e51ac02d5f2:/# python
Python 3.7.15 (default, Nov 15 2022, 22:40:13) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import trimesh
>>> m = trimesh.creation.box()
>>> m.voxelized(pitch=0.5)
<trimesh.VoxelGrid(3, 3, 3)>

3.5:

mikedh@orion:~/trimesh$ docker run -it python:3.5-slim-jessie /bin/bash
Unable to find image 'python:3.5-slim-jessie' locally
3.5-slim-jessie: Pulling from library/python
0f4b58aabdee: Pull complete 
b8b3b2216ffd: Pull complete 
b9e422555895: Pull complete 
da961b72154c: Pull complete 
60f1166a469c: Pull complete 
Digest: sha256:65565b3fe96165605eed956f744578f4b441d43a034c4295e7f0c75d4b633bdd
Status: Downloaded newer image for python:3.5-slim-jessie
root@5478cfe719ba:/# pip install trimesh
Collecting trimesh
  Downloading https://files.pythonhosted.org/packages/b4/42/a492d2b067bde58696d447127f8df374302cbc4cd30371590982998b7af0/trimesh-3.16.4-py3-none-any.whl (663kB)
     |████████████████████████████████| 665kB 2.3MB/s 
Collecting numpy (from trimesh)
  Downloading https://files.pythonhosted.org/packages/b5/36/88723426b4ff576809fec7d73594fe17a35c27f8d01f93637637a29ae25b/numpy-1.18.5-cp35-cp35m-manylinux1_x86_64.whl (19.9MB)
     |████████████████████████████████| 19.9MB 19.2MB/s 
Installing collected packages: numpy, trimesh
Successfully installed numpy-1.18.5 trimesh-3.16.4
WARNING: You are using pip version 19.1.1, however version 20.3.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@5478cfe719ba:/# python
Python 3.5.7 (default, Jul 10 2019, 03:30:50) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import trimesh
>>> m = trimesh.creation.box()
>>> m.voxelized(pitch=0.5)
<trimesh.VoxelGrid(3, 3, 3)>

2.7:

mikedh@orion:~/trimesh$ docker run -it python:2.7-slim-jessie /bin/bash
Unable to find image 'python:2.7-slim-jessie' locally
2.7-slim-jessie: Pulling from library/python
0f4b58aabdee: Already exists 
79c9d6017da5: Pull complete 
a1d950e6ac24: Pull complete 
8ca451ccc0e0: Pull complete 
Digest: sha256:969a97a1cae4f1796104ebee4c4ec6ecb6bc81120d03498d56feebd5820cba93
Status: Downloaded newer image for python:2.7-slim-jessie
root@b8585ef6b82e:/# pip install trimesh
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting trimesh
  Downloading https://files.pythonhosted.org/packages/66/7c/713c0b5e18babb223e80507dae1e6ca414283254d59db8007ebc72c89316/trimesh-3.16.4.tar.gz (617kB)
     |████████████████████████████████| 624kB 5.7MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting numpy (from trimesh)
  Downloading https://files.pythonhosted.org/packages/3a/5f/47e578b3ae79e2624e205445ab77a1848acdaa2929a00eeef6b16eaaeb20/numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl (17.0MB)
     |████████████████████████████████| 17.0MB 11.2MB/s 
Building wheels for collected packages: trimesh
  Building wheel for trimesh (PEP 517) ... done
  Stored in directory: /root/.cache/pip/wheels/3d/00/bc/93b8cae8cd6a524d0d452a14b2fa5cc26b30f8d995940380a7
Successfully built trimesh
Installing collected packages: numpy, trimesh
Successfully installed numpy-1.16.6 trimesh-3.16.4
WARNING: You are using pip version 19.1.1, however version 20.3.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@b8585ef6b82e:/# python
Python 2.7.16 (default, Jul 10 2019, 03:46:34) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import trimesh
>>> m = trimesh.creation.box()
>>> m.voxelized(pitch=0.5)
<trimesh.VoxelGrid(3, 3, 3)>
>>> m.voxelized(pitch=0.5).volume
3.250000000000001

mikedh avatar Nov 17 '22 21:11 mikedh

My bad, it's not exactly the same error, it's rather related to trimesh.voxel.creation, but it looks very similar.

merlin@L-0219:/workspace$ python3
Python 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import trimesh
>>> mesh = trimesh.Trimesh()
>>> n = trimesh.voxel.creation.local_voxelize(mesh, (0, 0, 0), 0.0, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'trimesh.voxel' has no attribute 'creation'
>>> from trimesh.voxel import creation
>>> n = trimesh.voxel.creation.local_voxelize(mesh, (0, 0, 0), 0.0, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/trimesh/voxel/creation.py", line 120, in local_voxelize
    faces = list(mesh.triangles_tree.intersection(bounds))
  File "/usr/local/lib/python3.10/dist-packages/trimesh/caching.py", line 139, in get_cached
    value = function(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/trimesh/base.py", line 797, in triangles_tree
    tree = triangles.bounds_tree(self.triangles)
  File "/usr/local/lib/python3.10/dist-packages/trimesh/triangles.py", line 344, in bounds_tree
    tree = util.bounds_tree(triangle_bounds)
  File "/usr/local/lib/python3.10/dist-packages/trimesh/util.py", line 1733, in bounds_tree
    import rtree
ModuleNotFoundError: No module named 'rtree'
>>> 

The call fails in the "working" (i.e. 2nd) case because the missing rtree dependency (as already reported by @alexge233), but we see that the first call fails because trimesh.voxel has no creation attribute.

chlongv avatar Nov 18 '22 08:11 chlongv