1453528992 发表于 2021-4-13 10:14:06

AttributeError问题

因工作需要python与建模软件结合,用的是python2.6版本,运行软件包中python文件出现以下问题:
1.首先运行网格划分程序,里面基本上都是网格划分软件CUBIT的命令,运行后出现以下问题:
Traceback (most recent call last):
File "C:\CUBIT\examples\layered_halfspace\2lay_mesh_boundary_fig8-nodoubling.py", line 9, in <module>
    import cubit
File "C:\CUBIT\examples\layered_halfspace\cubit.py", line 3973, in <module>
    class CubitFailureException(_object):
File "C:\CUBIT\examples\layered_halfspace\cubit.py", line 3990, in CubitFailureException
    __swig_destroy__ = _cubit.delete_cubitFailureException
AttributeError: 'module' object has no attribute 'delete_cubitFailureException'
2.检查cubit.py中的3973行到3993行的代码,将这段代码注释后运行发现python未报错且自动关闭:
class CubitFailureException(_object):
    """Proxy of C++ CubitInterface::CubitFailureException class"""
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, CubitFailureException, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, CubitFailureException, name)
    __repr__ = _swig_repr
    def what(self):
      """what(self) -> char"""
      return _cubit.CubitFailureException_what(self)

    def __init__(self):
      """__init__(self) -> CubitFailureException"""
      this = _cubit.new_cubitFailureException()
      try: self.this.append(this)
      except: self.this = this
      # _cubit.print_error(self, "*args")
    __swig_destroy__ = _cubit.delete_cubitFailureException
    __del__ = lambda self : None;
CubitFailureException_swigregister = _cubit.CubitFailureException_swigregister
CubitFailureException_swigregister(CubitFailureException)
3.PS:咨询过学python的朋友,并让他远程操作,他给我的解释是cubit.py中有import_cubit,而后我在软件包里找到了_cubit.pyd的文件,将代码里的import_cubit改成import_cubit.pyd后运行出现以上错误情况,朋友的解应该是_cubit.pyd里没有找到这个方法,所以引用会报错。
哪位大佬能帮忙看看指导指导,不胜感激!!!
页: [1]
查看完整版本: AttributeError问题