Runtime Error

Hi All,

I installed the matplotlib0.91.2 on 64-bit Ubuntu7.04 system. I ran an
example code and got the error:

  File "testplot.py", line 2, in <module>
    from pylab import *
  File "/usr/lib/python2.5/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 639,
in <module>
    rcParams = rc_params()
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 562,
in rc_params
    fname = matplotlib_fname()
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 513,
in matplotlib_fname
    fname = os.path.join(get_configdir(), 'matplotlibrc')
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 207,
in wrapper
    ret = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 400,
in _get_configdir
    raise RuntimeError("'%s' is not a writable dir; you must set
%s/.matplotlib to be a writable dir. You can also set environment variable
MPLCONFIGDIR to any writable directory where you want matplotlib data stored
"%h)
TypeError: not enough arguments for format string

How can I get it fixed?

Thanks,
Brook

···

--
View this message in context: http://www.nabble.com/Runtime-Error-tp16239554p16239554.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

We might be in a better position to help if you post the example code.

···

On Sunday 23 March 2008 2:23:36 pm Brook Lin wrote:

Hi All,

I installed the matplotlib0.91.2 on 64-bit Ubuntu7.04 system. I ran an
example code and got the error:

  File "testplot.py", line 2, in <module>
    from pylab import *
  File "/usr/lib/python2.5/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 639,
in <module>
    rcParams = rc_params()
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 562,
in rc_params
    fname = matplotlib_fname()
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 513,
in matplotlib_fname
    fname = os.path.join(get_configdir(), 'matplotlibrc')
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 207,
in wrapper
    ret = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 400,
in _get_configdir
    raise RuntimeError("'%s' is not a writable dir; you must set
%s/.matplotlib to be a writable dir. You can also set environment variable
MPLCONFIGDIR to any writable directory where you want matplotlib data
stored "%h)
TypeError: not enough arguments for format string

How can I get it fixed?

This bug was first pointed out by Mark Hamilton (with a patch) in the
thread "RuntimeError in _get_configdir". I've committed his fix to
svn. Basically, the format string is looking for two arguments where
only one is provided. Because it only arises in an error condition,
it is a corner of the code that had not been hit before.

JDH

···

On Sun, Mar 23, 2008 at 8:51 PM, Darren Dale <darren.dale@...163...> wrote:

> raise RuntimeError("'%s' is not a writable dir; you must set
> %s/.matplotlib to be a writable dir. You can also set environment variable
> MPLCONFIGDIR to any writable directory where you want matplotlib data
> stored "%h)
> TypeError: not enough arguments for format string
>
> How can I get it fixed?

We might be in a better position to help if you post the example code.

Hi Brook,

Brook Lin wrote:

    raise RuntimeError("'%s' is not a writable dir; you must set
%s/.matplotlib to be a writable dir. You can also set environment variable
MPLCONFIGDIR to any writable directory where you want matplotlib data stored
"%h)

This is the crucial bit.

Looks like you've set MPLCONFIGDIR to a read-only dir, or the .matplotlib in the current dir or .matplotlib in your home directory aren't writeable by the user running your python script. (I'm doing a bit of guesswork here...)

What is it that you're trying to do?

cheers,

Chris

···

--
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk

After installation, I only ran a simple code attached below. I found that I
got this run time error from "from pylab import *".

I did go through what Mark Hamilton posted:
Index: cutils.py

···

===================================================================
--- cutils.py (revision 5001)
+++ cutils.py (working copy)
@@ -79,7 +79,7 @@
             raise RuntimeError("""\
'%s' is not a writable dir; you must set %s/.matplotlib to be a writable
dir.
You can also set environment variable MPLCONFIGDIR to any writable
directory
-where you want matplotlib data stored """%h)
+where you want matplotlib data stored """%(p,h))
     else:
         if not is_writable_dir(h):
             raise RuntimeError("Failed to create %s/.matplotlib; consider
setting MPLCONFIGDIR to a writable directory for matplotlib configuration
data"%h)

I changed where you want matplotlib data stored """%h) into where you want
matplotlib data stored """%(p,h)). However, I got the same error after
changes. Did I do right?

I install matplotlib by:
python setup.py build
python setup.py install
How can I install it by svn trunk?

Appreciated,
Brook

=============
from pylab import *
from matplotlib import *
from pylab import figure, close, show, nx
from matplotlib.figure import Figure
import time

x=arange(10)
y=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
x2=arange(20)
y2=arange(20)

f=figure()
hold(True)
plot(x,y)
plot(x2,y2)
grid()
pylab.show()
time.sleep(3)
pylab.close(f)

--
View this message in context: http://www.nabble.com/Runtime-Error-tp16239554p16257231.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

After installation, I only ran a simple code attached below. I found that I
got this run time error from "from pylab import *".

I did go through what Mark Hamilton posted:
Index: cutils.py

--- cutils.py (revision 5001)
+++ cutils.py (working copy)
@@ -79,7 +79,7 @@
             raise RuntimeError("""\
'%s' is not a writable dir; you must set %s/.matplotlib to be a writable
dir.
You can also set environment variable MPLCONFIGDIR to any writable
directory
-where you want matplotlib data stored """%h)
+where you want matplotlib data stored """%(p,h))
     else:
         if not is_writable_dir(h):
             raise RuntimeError("Failed to create %s/.matplotlib; consider
setting MPLCONFIGDIR to a writable directory for matplotlib configuration
data"%h)

I changed where you want matplotlib data stored """%h) into where you want
matplotlib data stored """%(p,h)). However, I got the same error after
changes. Did I do right?

Sorry, cutils.py is a part of a new config package we have been working on,
which ships with matplotlib but is not activated. I think you need to edit
your matplotlib/__init__.py instead, just make the same changes.

Once that change is made, and you try to import pylab, you should get a
RunTimeError telling you that matplotlib can't create the directory, either
because the path doesnt exist, or it exists but you cant write to it. At that
point you can set your MPLCONFIGDIR environment variable to point somewhere
writeable, and if it seems like a bug that matplotlib is trying to create a
directory somewhere nonsensical, please let us know.

I install matplotlib by:
python setup.py build
python setup.py install
How can I install it by svn trunk?

The following should be on one line:

···

On Monday 24 March 2008 01:52:27 pm Brook Lin wrote:

----
svn co
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib
matplotlib
----

then cd into the new directory and install in the usual way.

Darren