You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行fracture-modes脚本时遇igl模块'tet_tet_adjacency'属性错误

解决AttributeError: module 'igl' has no attribute 'tet_tet_adjacency'错误

问题详情

运行fracture-modes仓库的example.py脚本时触发以下错误,该问题在macOS、Windows(WSL及原生Miniconda环境)中均会出现。此前几周测试代码完全正常,推测是igl模块更新引发的兼容性问题。

运行python scripts/example.py的输出:

Starting fracture mode computation
We will find  10  unique fracture modes
Our input (unexploded) mesh has  1266  vertices and  4025  tetrahedra.
Traceback (most recent call last):
  File "/mnt/c/Users/al/Documents/fracture-modes/scripts/example.py", line 24, in <module>
    modes.compute_modes(parameters=params)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/mnt/c/Users/al/Documents/fracture-modes/fracture_utility/fracture_modes.py", line 32, in compute_modes
    self.exploded_vertices,self.exploded_elements,self.modes, self.labels, self.tet_to_vertex_matrix,self.tet_neighbors,self.massmatrix,self.unexploded_to_exploded_matrix = compute_fracture_modes(self.vertices,self.elements,parameters)
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/c/Users/al/Documents/fracture-modes/fracture_utility/compute_fracture_modes.py", line 39, in compute_fracture_modes
    exploded_vertices, exploded_elements, discontinuity_matrix, unexploded_to_exploded_matrix, tet_to_vertex_matrix, tet_neighbors = explode_mesh(vertices,elements,num_quad=1)
                                                                                                                                     ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/c/Users/al/Documents/fracture-modes/fracture_utility/explode_mesh.py", line 36, in explode_mesh
    TT, TTi = igl.tet_tet_adjacency(elements)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'igl' has no attribute 'tet_tet_adjacency'

解决方案

方案1:锁定igl到兼容版本

找到之前代码正常运行时的igl版本(可通过conda/pip历史记录查询),执行以下命令安装指定版本:

pip install igl==<历史可用版本号>
# 或conda环境下
conda install igl==<历史可用版本号>

例如若之前使用的是2.2.0版本,执行:

pip install igl==2.2.0

方案2:替换函数适配新版igl

若需使用最新版igl,可查找tet_tet_adjacency的替代接口。例如可改用igl.tet_neighbors函数(需确认参数匹配),修改explode_mesh.py第36行代码:

# 原代码
TT, TTi = igl.tet_tet_adjacency(elements)
# 替换为(示例,需根据新版igl文档调整)
TT, TTi = igl.tet_neighbors(elements)

具体替代函数需参考igl官方文档确认参数和返回值是否一致。

原因分析

近期igl模块的版本更新中,可能移除了tet_tet_adjacency函数,导致旧代码调用时触发属性不存在的错误。

内容的提问来源于stack exchange,提问作者albusdemens

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 13:25:05