Issue with Running fenics for the 1st time

Hi,
I installed fenics on ubuntu 18.04 and I want to run the poisson demo on the ubuntu 18.04 terminal , unfortunately it gives the gives following message an i as a beginner do not know how to solve this,
I would be thankful if u could help me to run my first simulation with fenics.

Here is my command to run:

mhd@mhd-N552VW:/usr/share/dolfin/demo-python/documented/poisson$ python3 demo_poisson.py

Here is the result:

Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
File “demo_poisson.py”, line 90, in
V = FunctionSpace(mesh, “Lagrange”, 1)
File “/usr/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 33, in init
self._init_convenience(*args, **kwargs)
File “/usr/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 100, in _init_convenience
self._init_from_ufl(mesh, element, constrained_domain=constrained_domain)
File “/usr/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 43, in _init_from_ufl
mpi_comm=mesh.mpi_comm())
File “/usr/lib/python3/dist-packages/dolfin/jit/jit.py”, line 47, in mpi_jit
return local_jit(*args, **kwargs)
File “/usr/lib/python3/dist-packages/dolfin/jit/jit.py”, line 97, in ffc_jit
return ffc.jit(ufl_form, parameters=p)
File “/usr/lib/python3/dist-packages/ffc/jitcompiler.py”, line 217, in jit
module = jit_build(ufl_object, module_name, parameters)
File “/usr/lib/python3/dist-packages/ffc/jitcompiler.py”, line 133, in jit_build
generate=jit_generate)
File “/usr/lib/python3/dist-packages/dijitso/jit.py”, line 178, in jit
params)
File “/usr/lib/python3/dist-packages/dijitso/build.py”, line 153, in build_shared_library
status, output = get_status_output(cmd)
File “/usr/lib/python3/dist-packages/dijitso/system.py”, line 41, in _get_status_output_subprocess
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File “/usr/lib/python3.6/subprocess.py”, line 709, in init
restore_signals, start_new_session)
File “/usr/lib/python3.6/subprocess.py”, line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘c++’: ‘c++’

It looks like you might not have c++ installed.
What does ‘which c++’ return?
And ‘dpkg -l "*g++*"’?
If g++ is not there, then install it

Thank you for your reply,
It gives the following answers:

  1. /usr/bin/c++

  2. Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name Version Architecture Description
    ++±==============-============-============-=================================
    ii g++ 4:7.4.0-1ubu amd64 GNU C++ compiler

After reinstalling c++,
I faced the below message:

python3 demo_poisson.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Solving linear variational problem.
Traceback (most recent call last):
File “demo_poisson.py”, line 185, in
file << u
File “/usr/lib/python3/dist-packages/dolfin/io/init.py”, line 14, in lshift
self.write(u._cpp_object)
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 write to file.
*** Reason: Unable to open file “poisson.pvd” for writing.
*** Where: This error was encountered inside GenericFile.cpp.
*** Process: 0***
*** DOLFIN version: 2019.1.0
*** Git changeset: unknown
*** -------------------------------------------------------------------------

Here the problem looks like file permissions. You were running from /usr/share/dolfin/demo-python/documented/poisson, which is read-only (to normal users).

Copy the demo file (or dir) to your own directory and try from there.

thank you dparsons,
After following your guidance, i faced the below Error:
how can i solve this error?

Solving linear variational problem.
Traceback (most recent call last):
File “demo_poisson.py”, line 188, in
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named ‘matplotlib’

Error is due to missing module. Install matplotlib module.

Thank you very much amarendernag,
The problem solved.

For those who followed the topic i did as follows:

  1. Update c++
  2. Update the default python of ubuntu 18.04 from 2.7 to 3.6 because the matplot modul doesnt work for python below 3.6
  3. Download thw matplotlib
  4. Run the demo on ubuntu desktop