Problem define Measure

I just updated to Ubuntu 18.04. The code that used to work normally now has the following error:

Invalid cell <module ‘dolfin.mesh’ from ‘/usr/lib/python3/dist-packages/dolfin/mesh/init.py’>.
Traceback (most recent call last):
File “cavity.py”, line 253, in
ds = Measure(‘ds’, domain=mesh, subdomain_data=boundaries)
File “/usr/lib/python3/dist-packages/ufl/measure.py”, line 158, in init
self._domain = None if domain is None else as_domain(domain)
File “/usr/lib/python3/dist-packages/ufl/domain.py”, line 296, in as_domain
cell = as_cell(domain)
File “/usr/lib/python3/dist-packages/ufl/cell.py”, line 329, in as_cell
error(“Invalid cell %s.” % cell)
File “/usr/lib/python3/dist-packages/ufl/log.py”, line 172, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Invalid cell <module ‘dolfin.mesh’ from ‘/usr/lib/python3/dist-packages/dolfin/mesh/init.py’>.

Thank you advance.

You probably forgot to define mesh as an object of type Mesh, e.g.,

mesh = UnitSquareMesh(10,10)

or similar, before the line

ds = Measure(‘ds’, domain=mesh, subdomain_data=boundaries)

so mesh in this line refers to the module dolfin.mesh, which doesn’t make sense in this context.

I defined the mesh previously as

mesh = Mesh(" meshname.xml.gz")

The only other thing I can think of is that somehow the module is being re-imported (possibly through another module) after defining mesh, e.g.,

from dolfin import *
#ds = Measure('ds',domain=mesh) # Reproduces error
mesh = UnitSquareMesh(1,1)
ds = Measure('ds',domain=mesh) # No error
from dolfin import *
ds = Measure('ds',domain=mesh) # Reproduces error

Thanks. I will check my code