I recently shifted to a new laptop. After installing Ubuntu 14.04 LTS and all of the packages that my previous system contained, I copied all my files from my old system to the new one.
Whenever I try executing any python code that has a matplotlib call, I get the following error
File "Q1.py", line 2, in <module>
import matplotlib.pyplot as plt
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 24, in <module>
import matplotlib.colorbar
File "/usr/lib/pymodules/python2.7/matplotlib/colorbar.py", line 29, in <module>
import matplotlib.collections as collections
File "/usr/lib/pymodules/python2.7/matplotlib/collections.py", line 23, in <module>
import matplotlib.backend_bases as backend_bases
File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 50, in <module>
import matplotlib.textpath as textpath
File "/usr/lib/pymodules/python2.7/matplotlib/textpath.py", line 11, in <module>
import matplotlib.font_manager as font_manager
File "/usr/lib/pymodules/python2.7/matplotlib/font_manager.py", line 1356, in <module>
_rebuild()
File "/usr/lib/pymodules/python2.7/matplotlib/font_manager.py", line 1343, in _rebuild
pickle_dump(fontManager, _fmcache)
File "/usr/lib/pymodules/python2.7/matplotlib/font_manager.py", line 939, in pickle_dump
with open(filename, 'wb') as fh:
IOError: [Errno 2] No such file or directory: '/tmp/matplotlib-skarthikkrishna/fontList.cache'
From what I've been able to try, this problem seems to crop up because the code cannot access /tmp/ for writing onto it. The code runs just fine when I add a sudo tag before the execution command.
I'm curious as to why this is happening now. All the packages on my old and new laptop, especially the pyplot package are the same. I haven't missed out on installing any package, nor has there been any update that is not reflected in one of the systems. The code runs just fine in my old laptop. It refuses to work without sudo in the new one. I'd appreciate it if someone could help me out on that
A few details, if they are relevant:
Both systems run Ubuntu 14.04 LTS, last upgraded on 26th Dec, 2014.
I'm running Python 2.7.6 on both systems. [It's a mandated requirement for most of my coursework]
Matplotlib version installed on both systems is 1.3.1
EDIT :
The output of ls -ld /tmp/ is
drwxrwxrwt 4 root root 4096 Dec 27 18:45 /tmp/
The output of ls -ld /tmp/matplotlib-skarthikkrishna is
ls: cannot access /tmp/matplotlib-skarthikkrishna: No such file or directory
The output remains the same with and without sudo, if at all that is relevant.
/tmp
and/tmp/matplotlib-skarthikkrishna
have the right read/write/execute permissions? Might be helpful if you add the output ofls -ld /tmp/
andls -ld /tmp/matplotlib-skarthikkrishna
to your question. – cel Dec 27 '14 at 13:45sudo apt-get install matplotlib
or viapip install matplotlib?
? – jkalden Dec 27 '14 at 13:47sudo apt-get install python-matplotlib
to install matplotlib on both systems – Karthik Krishna Subramanian Dec 27 '14 at 23:58