Error with FunctionSpace

Hi #Fenics!

I encounter the error below when trying to use Fenics on Ubuntu 18.04. Would anyone know what the issue is?

Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import fenics
>>> mesh = fenics.UnitSquareMesh(5, 5)
>>> fenics.FunctionSpace(mesh, 'P', 1)

Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/dolfin/compilemodules/jit.py", line 142, in jit
    result = ffc.jit(ufl_object, parameters=p)
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 218, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 134, in jit_build
    generate=jit_generate)
  File "/usr/lib/python3/dist-packages/dijitso/jit.py", line 167, in jit
    header, source, dependencies = generate(jitable, name, signature, params["generator"])
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 67, in jit_generate
    prefix=module_name, parameters=parameters, jit=True)
  File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 150, in compile_element
    prefix, parameters, jit)
  File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 190, in compile_ufl_objects
    ir = compute_ir(analysis, prefix, parameters, jit)
  File "/usr/lib/python3/dist-packages/ffc/representation.py", line 171, in compute_ir
    for e in elements]
  File "/usr/lib/python3/dist-packages/ffc/representation.py", line 171, in <listcomp>
    for e in elements]
  File "/usr/lib/python3/dist-packages/ffc/representation.py", line 203, in _compute_element_ir
    fiat_element = create_element(ufl_element)
  File "/usr/lib/python3/dist-packages/ffc/fiatinterface.py", line 99, in create_element
    element = _create_fiat_element(ufl_element)
  File "/usr/lib/python3/dist-packages/ffc/fiatinterface.py", line 196, in _create_fiat_element
    element = ElementClass(fiat_cell, degree)
  File "/usr/lib/python3/dist-packages/FIAT/lagrange.py", line 56, in __init__
    poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
  File "/usr/lib/python3/dist-packages/FIAT/polynomial_set.py", line 176, in __init__
    dv = expansion_set.tabulate_derivatives(degree, pts)
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 262, in tabulate_derivatives
    data = _tabulate_dpts(self._tabulate, 2, n, order, numpy.array(pts))
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 104, in _tabulate_dpts
    phi.append(form_derivative(phi[-1]))
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 50, in form_derivative
    out = [sympy.diff(F, X[j]) for j in range(D)]
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 50, in <listcomp>
    out = [sympy.diff(F, X[j]) for j in range(D)]
  File "/usr/local/lib/python3.6/dist-packages/sympy/core/function.py", line 2314, in diff
    return Derivative(f, *symbols, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/sympy/core/function.py", line 1198, in __new__
    it cannot be differentiated.''' % expr))
ValueError: 
Since there are no variables in the expression [0, 0], it cannot be
differentiated.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/dolfin/functions/functionspace.py", line 199, in __init__
    self._init_convenience(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/dolfin/functions/functionspace.py", line 249, in _init_convenience
    constrained_domain=constrained_domain)
  File "/usr/lib/python3/dist-packages/dolfin/functions/functionspace.py", line 218, in _init_from_ufl
    dolfin_element, dolfin_dofmap = _compile_dolfin_element(element, mesh, constrained_domain=constrained_domain)
  File "/usr/lib/python3/dist-packages/dolfin/functions/functionspace.py", line 82, in _compile_dolfin_element
    ufc_element, ufc_dofmap = jit(element, mpi_comm=mesh.mpi_comm())
  File "/usr/lib/python3/dist-packages/dolfin/compilemodules/jit.py", line 70, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/dolfin/compilemodules/jit.py", line 147, in jit
    "ffc.jit failed with message:\n%s" % (tb_text,))
  File "/usr/lib/python3/dist-packages/dolfin/cpp/common.py", line 2044, in dolfin_error
    return _common.dolfin_error(location, task, reason)
RuntimeError: 

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to perform just-in-time compilation of form.
*** Reason:  ffc.jit failed with message:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/dolfin/compilemodules/jit.py", line 142, in jit
    result = ffc.jit(ufl_object, parameters=p)
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 218, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 134, in jit_build
    generate=jit_generate)
  File "/usr/lib/python3/dist-packages/dijitso/jit.py", line 167, in jit
    header, source, dependencies = generate(jitable, name, signature, params["generator"])
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 67, in jit_generate
    prefix=module_name, parameters=parameters, jit=True)
  File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 150, in compile_element
    prefix, parameters, jit)
  File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 190, in compile_ufl_objects
    ir = compute_ir(analysis, prefix, parameters, jit)
  File "/usr/lib/python3/dist-packages/ffc/representation.py", line 171, in compute_ir
    for e in elements]
  File "/usr/lib/python3/dist-packages/ffc/representation.py", line 171, in <listcomp>
    for e in elements]
  File "/usr/lib/python3/dist-packages/ffc/representation.py", line 203, in _compute_element_ir
    fiat_element = create_element(ufl_element)
  File "/usr/lib/python3/dist-packages/ffc/fiatinterface.py", line 99, in create_element
    element = _create_fiat_element(ufl_element)
  File "/usr/lib/python3/dist-packages/ffc/fiatinterface.py", line 196, in _create_fiat_element
    element = ElementClass(fiat_cell, degree)
  File "/usr/lib/python3/dist-packages/FIAT/lagrange.py", line 56, in __init__
    poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
  File "/usr/lib/python3/dist-packages/FIAT/polynomial_set.py", line 176, in __init__
    dv = expansion_set.tabulate_derivatives(degree, pts)
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 262, in tabulate_derivatives
    data = _tabulate_dpts(self._tabulate, 2, n, order, numpy.array(pts))
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 104, in _tabulate_dpts
    phi.append(form_derivative(phi[-1]))
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 50, in form_derivative
    out = [sympy.diff(F, X[j]) for j in range(D)]
  File "/usr/lib/python3/dist-packages/FIAT/expansions.py", line 50, in <listcomp>
    out = [sympy.diff(F, X[j]) for j in range(D)]
  File "/usr/local/lib/python3.6/dist-packages/sympy/core/function.py", line 2314, in diff
    return Derivative(f, *symbols, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/sympy/core/function.py", line 1198, in __new__
    it cannot be differentiated.'''  6.909194e-310xpr))
ValueError: 
Since there are no variables in the expression [0, 0], it cannot be
differentiated.
.
*** Where:   This error was encountered inside jit.py.
*** Process: 0
*** 
*** DOLFIN version: 2017.2.0
*** Git changeset:  unknown
*** -------------------------------------------------------------------------

As far as I know, fenics was installed by apt install python3-dolfin. The linux distribution is the following:

Linux macomp001 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Try uninstalling python3-dolfin and following the Ubuntu instructions here: