Issue with gmshio import

I’m working with dolfinx via Google Colab, and I’m having some problems with

I have gmsh installed in the notebook, and I’m trying to use the extract_geometry and extract_topology_and_markers methods. However, I get AttributeError: module '' has no attribute 'extract_geometry'.

When calling gmshio._has_gmsh, the console returns False, and gmshio.__all__ only gives the list ['cell_perm_array', 'ufl_mesh'], where "extract_topology_and_markers", "extract_geometry", "model_to_mesh", "read_from_msh" are missing.

Here are the blocks I’m running on Colab:

    import dolfinx
except ImportError:
    !wget "" -O "/tmp/" && bash "/tmp/"
    import dolfinx
!pip install -q gmsh
import gmsh
from import gmshio

Any idea on why is this happening?
Thanks in advance.

As you can see from the source code: dolfinx/ at main · FEniCS/dolfinx · GitHub _has_gmsh only checks if one can import gmsh.
What is the message you get if you call import gmsh?

Hi dokken,

When I run import gmsh the cell runs successfully. Moreover, running the lines manually for checking that one can import gmsh:

    import gmsh
    _has_gmsh = True
except ModuleNotFoundError:
    _has_gmsh = False

gives _has_gmsh with _has_gmsh==True

I would have to ask @francesco-ballarin for his thoughts. I dont know much about how the installation process for colab is.

Okay. I’ll be looking forward to your answer. Thanks!

Make sure to install the gmsh provided by fem on colab BEFORE installing FEniCSx

1 Like