When using Apache + python-cgi, I encounter this error:
<type ‘exceptions.RuntimeError’>: Failed to create /$dirstring$/common/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
An official explanation of MPLCONFIGDIR is here.
MPLCONFIGDIR This is the directory used to store user customizations to matplotlib, as well as some caches to improve performance. If MPLCONFIGDIR is not defined, HOME/.matplotlib is used by default.
It turns out that on my windows machine HOME/.matplotlib is now writable. Here’s a way to simply bypass this problem.
Find out the place where you first import matplotlib, right before it, set the $HOME dir to a temporary dir where it’s writable:
For example, I was importing matplotlib in an indirect way through “from scipy.cluster.vq import kmeans2“, so right before it, do
os.environ[‘HOME’] = r’C:\……\Apache2.2\htdocs\tmp’
from scipy.cluster.vq import kmeans2
Struggling for a while to install matplotlib on my mac, finally find this one works:
First install brew: <http://mxcl.github.com/homebrew>
And following the instruction posted here.
$ brew install python $ brew install gfortran $ brew install pkg-config $ easy_install pip $ pip install numpy $ cd $HOME $ git clone https://github.com/matplotlib/matplotlib.git $ cd matplotlib $ python setup.py build $ python setup.py install
Well, then continue for my scipy 🙂
Here’s a ‘investigation‘ that i found, very useful. The official scipy/numpy site only say that CC, XCC, etc needs to be changed, but not for the fortran part. For my case, I did’t export the CC, etc — it not works for me, but I deed have fcompile specified.
mkdir ~/tmp cd ~/tmp git clone https://github.com/scipy/scipy.git cd scipy python setupegg.py build --fcompiler=gfortran sudo python setupegg.py install
sudo pip install nose