<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> You can also just add --with-petsc4py to your PETSc configure command and it will manage automatically the petsc4py install. So<div class=""><br class=""></div><div class=""><span style="font-size: 13px;" class="">./configure --with-hdf5 --any-other --configure-flags --you-want --with-petsc4py</span></div><div class=""><font size="2" class=""><br class=""></font></div><div class=""><font size="2" class=""><br class=""></font><div> Some people don't like this approach, I don't understand exactly why not; it should be equivalent (if it is not equivalent then perhaps it could be fixed?).</div><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 7, 2021, at 10:18 AM, Lawrence Mitchell <<a href="mailto:wence@gmx.li" class="">wence@gmx.li</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Comments inline below:<br class=""><br class=""><blockquote type="cite" class="">On 7 Dec 2021, at 14:43, Quentin Chevalier <<a href="mailto:quentin.chevalier@polytechnique.edu" class="">quentin.chevalier@polytechnique.edu</a>> wrote:<br class=""><br class="">@Matthew, as stated before, error output is unchanged, i.e.the python<br class="">command below produces the same traceback :<br class=""><br class=""># python3 -c "from petsc4py import PETSc; PETSc.Viewer().createHDF5('d.h5')"<br class="">Traceback (most recent call last):<br class=""> File "<string>", line 1, in <module><br class=""> File "PETSc/Viewer.pyx", line 182, in petsc4py.PETSc.Viewer.createHDF5<br class="">petsc4py.PETSc.Error: error code 86<br class="">[0] PetscViewerSetType() at<br class="">/usr/local/petsc/src/sys/classes/viewer/interface/viewreg.c:442<br class="">[0] Unknown type. Check for miss-spelling or missing package:<br class=""><a href="https://petsc.org/release/install/install/#external-packages" class="">https://petsc.org/release/install/install/#external-packages</a><br class="">[0] Unknown PetscViewer type given: hdf5<br class=""><br class="">@Wence that makes sense. I'd assumed that the original PETSc had been<br class="">overwritten, and if the linking has gone wrong I'm surprised anything<br class="">happens with petsc4py at all.<br class=""><br class="">Your tentative command gave :<br class=""><br class="">ERROR: Invalid requirement: '/usr/local/petsc/src/binding/petsc4py'<br class="">Hint: It looks like a path. File<br class="">'/usr/local/petsc/src/binding/petsc4py' does not exist.<br class=""><br class="">So I tested that global variables PETSC_ARCH & PETSC_DIR were correct<br class="">then ran "pip install petsc4py" to restart petsc4py from scratch.<br class=""></blockquote><br class="">This downloads petsc4py from pypi. It is not guaranteed to give you a version that matches the PETSc version you have installed (which is the source of your error below)<br class=""><br class=""><br class=""><blockquote type="cite" class="">This<br class="">gives rise to a different error :<br class=""><br class=""></blockquote>[...]<br class=""><blockquote type="cite" class="">ImportError: /usr/local/lib/python3.9/dist-packages/petsc4py/lib/linux-gnu-real-32/PETSc.cpython-39-x86_64-linux-gnu.so:<br class="">undefined symbol: petscstack<br class=""><br class="">Not sure that it a step forward ; looks like petsc4py is broken now.<br class=""></blockquote><br class="">The steps to build PETSc with HDF5 support and then get a compatible petsc4py are:<br class=""><br class="">1. Download the PETSc source somehow (<a href="https://petsc.org/release/download/" class="">https://petsc.org/release/download/</a>)<br class=""><br class="">I now assume that this source tree lives in .../petsc<br class=""><br class="">2. cd .../petsc<br class=""><br class="">3. ./configure --with-hdf5 --any-other --configure-flags --you-want<br class=""><br class="">4. Run the appropriate "make" command as suggested by configure<br class=""><br class="">5. Run the appropriate "make check" command as suggested by configure<br class=""><br class="">6. Set PETSC_DIR and PETSC_ARCH appropriately<br class=""><br class="">7. pip install src/binding/petsc4py<br class=""><br class="">If you are working the docker container from dolfinx/dolfinx, you can see the commands that are run to install PETSc, and then petsc4py, here <a href="https://github.com/FEniCS/dolfinx/blob/main/docker/Dockerfile#L243" class="">https://github.com/FEniCS/dolfinx/blob/main/docker/Dockerfile#L243</a><br class=""><br class="">If you want to reproduce these versions of PETSc but with the addition of HDF5 support, just add --with-hdf5 to all of the relevant configure lines.<br class=""><br class="">Lawrence<br class=""><br class=""><br class=""></div></div></blockquote></div><br class=""></div></body></html>