Missing 'gmshio' when using import function in Dolfinx 0.4.1

Dear all,

I am learning to use FeniCSX. I followed the instructions at github and installed fenicsx. Then I tried to run some tutorial cases. But the code cannot be executed due to the following errors. As for the installed version, the information shows that
DOLFINx version: 0.4.1 based on GIT commit: unknown of GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment

 from dolfinx.io import (VTXWriter, distribute_entity_data, gmshio)                                                  ImportError: cannot import name 'VTXWriter' from 'dolfinx.io' (/usr/lib/petsc/lib/python3/dist-packages/dolfinx/io.py)
ImportError: cannot import name 'gmshio' from 'dolfinx.io'

I have checked the document for dofinx 0.4.0, there is no ‘gmshio’, in the dolfinx.io module. I also tried to upgrade the most recent v0.6.0, but the ‘apt install fencisx’ says that ’ it is already the newest version’. There is no way to upgrade this Python version. Please help me out, thanks in avance.

You need to give more details about your installation. What operating system are you using, and which version? How exactly did you install fenicsx? Which tutorial are you trying to run?

To use gmshio you need to have both GMSH and its Python-API installed.

Thanks, Dokken. I have installed Gmsh and its python API. As shown below
Capture

Hi Dparsons, I use Ubuntu 20.04 and try to run flow over cylinder problems referred to Test problem 2: Flow past a cylinder (DFG 2D-3 benchmark) — FEniCSx tutorial. I can run other tutorials without ‘gmshio’, which means fenicsx was properly installed, not quite sure. But not be able to run this problem due to the importing error

Ok, simple enough. Ubuntu 20.04 is ubuntu focal. focal only supports dolfinx 0.4 since the later versions need C++20 support which gcc-9 doesn’t provide.

Your tutorial is @dokken 's tutorial. It’s configured against the latest release of dolfinx, which is v0.5. As you saw, dolfinx v0.5 introduces gmshio, so it won’t be available on your v0.4 installation.

You’ve got two options. Firstly, the latest ubuntu release 22.04 jammy does support dolfinx v0.5. If you upgrade your operating system to the latest version, your problem will be solved. I recommend doing this.

Secondly, if you can’t or prefer not to upgrade to ubuntu jammy, you could just ignore the problem. You’ve got a working installation of dolfinx 0.4, you can just use it, which means don’t use gmshio. If you track through the source code of dokken’s tutorial, you’ll be able to find the old version of that test problem working with dolfinx 0.4 (so that version won’t be using gmshio).

A third option is to use dolfinx via docker instead of using the debian/ubuntu packages.

2 Likes

Thanks, Dparsons. I will follow your suggestion and upgrade my Ubuntu to 22.04 and install dolfinx v0.5. Hopefully this will resolve the annoying importing problem

Thanks for your help, Dparsons. I have upgraded my Ubuntu from 20.02 to 22.04 and reinstalled dolfinx (v0.5.0). Now I can import ‘gmshio’ and use it to import mesh files. However, I cannot use ‘VTXWriter’ due to the same import error, as is shown below. Any suggestions about this problem

VTX (adios2) is not yet available in the debian/ubuntu packages.

Request for it has been made at #960339 - ITP: adios2 -- Adaptable IO system for simulations - Debian Bug report logs, but it has a complex set of dependencies which need to be packaged first.

Thanks, I will avoid using VTXWriter and write data in other formats.