I am able to generate *.dat file:
vikas@server:~/memory_profiler-0.36$ ./mprof run --python test_sl.py
vikas@server:~/memory_profiler-0.36$ ls *.dat
mprofil
You need to install matplotlib, as instructed (this error in thrown by mprof when it can't find matplotlib).
You can do so using pip pip install matplotlib (you might need to prefix this with sudo) or your package manager:
sudo apt-get install -y python-matplotlib on Debian, Ubuntu and derivatives.sudo yum install -y python-matplotlib on RHEL, CentOS and derivatives.