Fem.petsc not found in complex-mode

Dear FEniCS community.

I’m facing an AttributeError error when trying to run a code with complex-mode in Dolfinx v0.7.3 Docker image. The code below

import dolfinx
import ufl
import basix
from mpi4py import MPI


msh = dolfinx.mesh.create_interval(comm=MPI.COMM_WORLD,
                                   nx=10, points=[-1, 1])


Ph = basix.ufl.element("Lagrange", msh.basix_cell(), 1)

V = dolfinx.fem.functionspace(msh, Ph)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

K = -ufl.inner(ufl.grad(u), ufl.grad(v)) * ufl.dx
Kform = dolfinx.fem.form(K)

dolfinx.fem.petsc.assemble_matrix(Kform, bcs=[])

is followed by the error

AttributeError: module 'dolfinx.fem' has no attribute 'petsc'

This code runs ok if we use real-mode. I cannot reproduce this on the dolfinx conda installation.

Thanks in advance!

You should explicitly import the petsc sub-module,
ie
import dolfinx.fem.petsc.
This is because petsc is not a mandatory requirement.