import pylab does't work on windows - font error?

I can't get import pylab to work. My matplotlabrc file and some ipython output is attached. The font manager seems to fail. Any suggestions?


# This is a sample matplotlib configuration file. It should be placed
# in HOME/.matplotlib/matplotlibrc (unix/linux like systems) and
# C:\Documents and Settings\yourname\.matplotlib (win32 systems)


# By default, the installer will overwrite the existing file in the
# install path, so if you want to preserve your's, please move it to
# your HOME dir and set the environment variable if necessary.
# This file is best viewed in a editor which supports python mode
# syntax highlighting
# Blank lines, or lines starting with a comment symbol, are ignored,
# as are trailing comments. Other lines must have the format
# key : val # optional comment
# Colors: for the color values below, you can either use
# - a matplotlib color string, such as r, k, or b
# - an rgb tuple, such as (1.0, 0.5, 0.0)
# - a hex string, such as ff00ff (no '#' symbol)
# - a scalar grayscale intensity such as 0.75
# - a legal html color name, eg red, blue, darkslategray

# the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg
# Agg Cairo GD GDK Paint PS SVG Template
backend : GTKAgg
numerix : numpy # numpy, Numeric or numarray
interactive : False # see
toolbar : toolbar2 # None | classic | toolbar2
timezone : UTC # a pytz timezone string, eg US/Central or Europe/Paris

# Where your matplotlib data lives if you installed to a non-default
# location. This is where the matplotlib fonts, bitmaps, etc reside
datapath: C:\Python24\Lib\site-packages\matplotlib\mpl-data

# See for more
# information on line properties.
lines.linewidth : 1.0 # line width in points
lines.linestyle : - # solid line
lines.color : blue
lines.marker : None # the default marker
lines.markerfacecolor : blue
lines.markeredgecolor : black
lines.markeredgewidth : 0.5 # the line width around the marker symbol
lines.markersize : 6 # markersize, in points
lines.dash_joinstyle : miter # miter|round|bevel
lines.dash_capstyle : butt # butt|round|projecting
lines.solid_joinstyle : miter # miter|round|bevel
lines.solid_capstyle : projecting # butt|round|projecting
lines.antialiased : True # render lines in antialised (no jaggies)

# Patches are graphical objects that fill 2D space, like polygons or
# circles. See
# for more
# information on patch properties
patch.linewidth : 1.0 # edge width in points
patch.facecolor : blue
patch.edgecolor : black
patch.antialiased : True # render patches in antialised (no jaggies)

### FONT
# font properties used by text.Text. See
# for more
# information on font properties. The 6 font properties used for font
# matching are given below with their default values.
# The property has five values: 'serif' (e.g. Times),
# 'sans-serif' (e.g. Helvetica), 'cursive' (e.g. Zapf-Chancery),
# 'fantasy' (e.g. Western), and 'monospace' (e.g. Courier). Each of
# these font families has a default list of font names in decreasing
# order of priority associated with them.
# The property has three values: normal (or roman), italic
# or oblique. The oblique style will be used for italic, if it is not
# present.
# The font.variant property has two values: normal or small-caps. For
# TrueType fonts, which are scalable fonts, small-caps is equivalent
# to using a font size of 'smaller', or about 83% of the current font
# size.
# The font.weight property has effectively 13 values: normal, bold,
# bolder, lighter, 100, 200, 300, ..., 900. Normal is the same as
# 400, and bold is 700. bolder and lighter are relative values with
# respect to the current weight.
# The font.stretch property has 11 values: ultra-condensed,
# extra-condensed, condensed, semi-condensed, normal, semi-expanded,
# expanded, extra-expanded, ultra-expanded, wider, and narrower. This
# property is not currently implemented.
# The font.size property is the default font size for text, given in pts.
# 12pt is the standard value.
# : sans-serif : normal
font.variant : normal
font.weight : medium
font.stretch : normal
# note that font.size controls default text sizes. To configure
# special text sizes tick labels, axes, labels, title, etc, see the rc
# settings for axes and ticks. Special text sizes can be defined
# relative to font.size, using the following values: xx-small, x-small,
# small, medium, large, x-large, xx-large, larger, or smaller
font.size : 12.0
font.serif : New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Bitstream Vera Serif, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
font.sans-serif : Lucida Grande, Verdana, Geneva, Lucida, Bitstream Vera Sans, Arial, Helvetica, Avant Garde, sans-serif
font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive
font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy
font.monospace : Andale Mono, Bitstream Vera Sans Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace

### TEXT
# text properties used by text.Text. See
# for more
# information on text properties
text.color : black
text.usetex : False # use latex for all text handling. For more information, see
text.dvipnghack : False # some versions of dvipng don't handle
                              # alpha channel properly. Use True to correct and flush
                              # ~/.matplotlib/tex.cache before testing

### AXES
# default face and edge color, default tick sizes,
# default fontsizes for ticklabels, and so on. See
axes.hold : True # whether to clear the axes by default on
axes.facecolor : white # axes background color
axes.edgecolor : black # axes edge color
axes.linewidth : 1.0 # edge linewidth
axes.grid : False # display grid or not
axes.titlesize : 14 # fontsize of the axes title
axes.labelsize : 12 # fontsize of the x any y labels
axes.labelcolor : black
polaraxes.grid : True # display grid on polar axes

# see
xtick.major.size : 4 # major tick size in points
xtick.minor.size : 2 # minor tick size in points
xtick.major.pad : 4 # distance to major tick label in points
xtick.minor.pad : 4 # distance to the minor tick label in points
xtick.color : k # color of the tick labels
xtick.labelsize : 12 # fontsize of the tick labels
xtick.direction : in # direction: in or out

ytick.major.size : 4 # major tick size in points
ytick.minor.size : 2 # minor tick size in points
ytick.major.pad : 4 # distance to major tick label in points
ytick.minor.pad : 4 # distance to the minor tick label in points
ytick.color : k # color of the tick labels
ytick.labelsize : 12 # fontsize of the tick labels
ytick.direction : in # direction: in or out

grid.color : black # grid color
grid.linestyle : : # dotted
grid.linewidth : 0.5 # in points

### Legend
legend.isaxes : True
legend.numpoints : 4 # the number of points in the legend line
legend.fontsize : 14
legend.pad : 0.2 # the fractional whitespace inside the legend border
legend.markerscale : 1.0 # the relative size of legend markers vs. original
# the following dimensions are in axes coords
legend.labelsep : 0.010 # the vertical space between the legend entries
legend.handlelen : 0.05 # the length of the legend lines
legend.handletextsep : 0.02 # the space between the legend line and legend text
legend.axespad : 0.02 # the border between the axes and legend edge
legend.shadow : False

# See
figure.figsize : 8, 6 # figure size in inches
figure.dpi : 80 # figure dots per inch
figure.facecolor : 0.75 # figure facecolor; 0.75 is scalar gray
figure.edgecolor : white # figure edgecolor

# The figure subplot parameters. All dimensions are fraction of the
# figure width or height
figure.subplot.left : 0.125 # the left side of the subplots of the figure
figure.subplot.right : 0.9 # the right side of the subplots of the figure
figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure : 0.9 # the top of the subplots of the figure
figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots
figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots

image.aspect : free # free | preserve
image.interpolation : bilinear # see help(imshow) for options
image.cmap : jet # gray | jet
image.lut : 256 # the size of the colormap lookup table
image.origin : upper # lower | upper

# the default savefig params can be different for the GUI backends.
# Eg, you may want a higher resolution, or to make the figure
# background white
savefig.dpi : 100 # figure dots per inch
savefig.facecolor : white # figure facecolor when saving
savefig.edgecolor : white # figure edgecolor when saving

# tk backend params
tk.window_focus : False # Maintain shell focus for TkAgg
tk.pythoninspect : False # tk sets PYTHONINSEPCT

# ps backend params
ps.papersize : letter # executive, letter, legal, ledger, A0-A10, B0-B6, C0-C6
ps.useafm : False # use of afm fonts, results in small files
ps.usedistiller : False # can be: None, ghostscript or xpdf
                                           # Experimental: may produce smaller files.
                                           # xpdf intended for production of publication quality files,
                                           # but requires ghostscript, xpdf and ps2eps
ps.distiller.res : 6000 # dpi

# Set the verbose flags. This controls how much information
# matplotlib gives you at runtime and where it goes. Ther verbosity
# levels are: silent, helpful, debug, debug-annoying. Any level is
# inclusive of all the levels below it. If you setting is debug,
# you'll get all the debug and helpful messages. When submitting
# problems to the mailing-list, please set verbose to helpful or debug
# and paste the output into your report.
# The fileo gives the destination for any calls to
# These objects can a filename, or a filehandle like sys.stdout.
# You can override the rc default verbosity from the command line by
# giving the flags --verbose-LEVEL where LEVEL is one of the legal
# levels, eg --verbose-helpful.
# You can access the verbose instance in your code
# from matplotlib import verbose.
verbose.level : helpful # one of silent, helpful, debug, debug-annoying
verbose.fileo : sys.stdout # a log filename, sys.stdout or sys.stderr
Using the new pyreadline (thanks for participating in the testing!)
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.7.2.rc1 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from pylab import *
C:\Python24\lib\site-packages\matplotlib\ UserWarning: Bad val "
free" on line #199
         "image.aspect : free # free | preserve"
         in file "C:\Documents and Settings\norman\.matplotlib\matplotlibrc"
         not a valid aspect specification
   warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (
loaded rc file C:\Documents and Settings\norman\.matplotlib\matplotlibrc
matplotlib version 0.87.3
verbose.level debug
interactive is False
platform is win32
loaded modules: ['IPython.Prompts', 'IPython.pickleshare', '_bisect', 'distutils
', 'IPython.iplib', 'IPython.signal', 'random', 'IPython.FakeModule', 'ctypes.os
', 'gc', 'matplotlib.tempfile', 'IPython.bdb', 'distutils.sysconfig', 'ctypes._e
ndian', 'pytz.datetime', 'IPython.time', 'msvcrt', 'IPython.ipy_system_conf', 's
truct', 're', 'tempfile', 'pyreadline._ctypes', 'pprint', 'IPython.copy_reg', 'i
mp', 'IPython.OInspect', 'collections', 'IPython.pydoc', 'pylab', 'IPython.cStri
ngIO', 'IPython.rlineimpl', 'zipimport', 'string', 'pyreadline.traceback', 'IPyt
hon.winconsole', 'repr', 'matplotlib.__future__', 'IPython.cmd', 'datetime', 'IP
ython.Itpl', 'IPython.Debugger', '', 'IPython.excolors', 'IPython.Qu
eue', 'IPython.os', 'pyreadline.rlmain', 'bisect', '', 'signal', 'c
md', 'IPython.atexit', 'pydoc', 'pyreadline.console', 'token', 'IPython.ctypes',
  'shlex', 'IPython.glob', 'IPython.shlex', '', 'IPython.exceptions',
  '', 'IPython.struct', 'dis', 'cStringIO', 'IPython.wildcard', 'local
e', 'IPython.path', 'Queue', 'pyreadline.string', 'ipy_user_conf', 'IPython.type
s', 'operator', 'IPython.commands', 'encodings', 'IPython.platutils_win32', 'pyr
eadline.os', 'IPython.threading', 'bdb', 'IPython.ConfigLoader', 'pyreadline.glo
b', 'IPython.CrashHandler', 'pyreadline.ctypes', 'matplotlib.sys', 'encodings.ty
pes', 'ntpath', 'threading', 'new', 'pyreadline.exceptions', 'math', '
atutils_dummy', 'IPython.profile', 'IPython.ColorANSI', 'dateutil', 'optparse',
'UserDict', 'inspect', 'distutils.os', '_ctypes', 'IPython.hooks', 'exceptions',
  'ctypes', 'pyreadline', 'ctypes.struct', 'codecs', 'path', 'pickleshare', 'pytz
.bisect', 'md5', 'pyreadline.winconstants', 'commands', 'socket', 'thread', 'sre
', 'IPython.StringIO', 'traceback', 'IPython.pstats', 'itertools', 'opcode', 'IP
ython.msvcrt', 'pstats', 'IPython.tokenize', 'distutils.sys', 'os', 'pdb', 'ext_
rescapture', 'ipy_system_conf', 'IPython.traceback', '__future__', '_sre', 'IPyt
hon.Shell', 'IPython.ipmaker', '__builtin__', 'pyreadline.operator', 'matplotlib
.re', 'pyreadline.math', 'IPython', 'distutils.string', 'ctypes._ctypes', 'ctype
s.sys', 'matplotlib.datetime', 'IPython.codeop', 'errno', '_socket', 'binascii',
  'IPython.sys', '', 'sre_constants', 'pyreadline.init_rl', '
atutils_posix', 'pyreadline.clipboard', 'matplotlib.md5', 'types', 'IPython.genu
tils', 'tokenize', 'IPython.pdb', 'matplotlib.warnings', 'pyreadline.logger', 'm
atplotlib.dateutil', 'cPickle', 'pytz.sys', 'IPython.platutils', 'IPython.macro'
, '_codecs', 'IPython.token', '_locale', 'encodings.cp1252', 'IPython.IPython',
'IPython.string', 'pytz', 'IPython.__builtin__', 'clearcmd', 'copy', 'ext_rehash
dir', 'matplotlib.os', 'IPython.socket', 'pyreadline.keysyms', 'keyword', 'atexi
t', 'pyreadline.sys', 'StringIO', 'IPython.linecache', 'IPython.ipstruct', 'IPyt
hon.__main__', 'encodings.aliases', 'fnmatch', 'sre_parse', 'IPython.ultraTB', '
pickle', 'IPython.tempfile', 'IPython.Release', 'IPython.OutputTrap', 'copy_reg'
, 'sre_compile', '_random', 'IPython.ipy_user_conf', 'site', 'IPython.getopt', '
ctypes.itertools', 'IPython.inspect', '__main__', 'shutil', 'IPython.Magic', 'IP
ython.pprint', 'strop', 'IPython.bisect', 'IPython.PyColorize', 'IPython.textwra
p', 'IPython.shutil', 'encodings.codecs', 'gettext', 'IPython.pyreadline', 'pspe
rsistence', 'IPython.Logger', 'getopt', 'encodings.exceptions', 'nt', 'pytz.sets
', 'profile', 'IPython.readline', 'stat', '_ssl', 'warnings', 'IPython.deep_relo
ad', 'IPython.imp', 'glob', 'sets', 'textwrap', 'sys', 'ctypes.ctypes', 'codeop'
, 'readline', 'IPython.keyword', 'os.path', 'matplotlib', 'IPython.background_jo
bs', 'IPython.DPyGetOpt', 'IPython.cPickle', 'IPython.usage', 'matplotlib.distut
ils', 'pytz.tzinfo', 'distutils.errors', 'marshal', 'IPython.__future__', 'linec
ache', 'matplotlib.shutil', 'IPython.completer', 'time', 'matplotlib.pytz', 'pyr
eadline.release', 'IPython.ipapi']
numerix numpy 0.9.8
font search path ['C:\\Python24\\Lib\\site-packages\\matplotlib\\mpl-data']
exceptions.TypeError Traceback (most recent call

C:\Documents and Settings\norman\<ipython console>

----> 1 from matplotlib.pylab import *

     198 import mlab #so I can override hist, psd, etc...
--> 200 from axes import Axes, PolarAxes
     201 import backends
     202 from cbook import flatten, is_string_like, exception_to_str, popd, \

      13 import matplotlib.mlab
      14 from artist import Artist, setp
---> 15 from axis import XAxis, YAxis
      16 from cbook import iterable, is_string_like, flatten, enumerate, \
      17 allequal, dict_delall, popd, popall, silent_list

      23 from transforms import Value, blend_xy_sep_transform,\
      24 translation_transform, bbox_all, identity_transform
---> 25 from font_manager import FontProperties
      26 from text import Text, TextWithDash, _process_text_args
      27 from patches import bbox_artist

     987 warnings.warn('Could not match %s, %s, %s. Returning %s' % (nam
e, style, variant, self.defaultFont))
     989 return self.defaultFont
--> 991 fontManager = FontManager()

C:\Python24\Lib\site-packages\matplotlib\ in __init__(self, size,
     795 # Load TrueType fonts and create font dictionary.
--> 797 self.ttffiles = findSystemFonts(paths) + findSystemFonts()
     799 for fname in self.ttffiles:

C:\Python24\Lib\site-packages\matplotlib\ in findSystemFonts(font
paths, fontext)
     194 fontpaths = [fontdir]
     195 # now get all installed fonts directly...
--> 196 for f in win32InstalledFonts(fontdir):
     197 base, ext = os.path.splitext(f)
     198 if len(ext)>1 and ext[1:].lower()==fontext:

C:\Python24\Lib\site-packages\matplotlib\ in win32InstalledFonts(
directory, fontext)
     120 try:
     121 key, direc, any = _winreg.EnumValue( local, j)
--> 122 if not os.path.dirname(direc):
     123 direc = os.path.join(directory, direc)
     124 direc = os.path.abspath(direc).lower()

C:\Python24\lib\ in dirname(p)
     205 def dirname(p):
     206 """Returns the directory component of a pathname"""
--> 207 return split(p)[0]

C:\Python24\lib\ in split(p)
     162 Either part may be empty."""
--> 164 d, p = splitdrive(p)
     165 # set i to index beyond p's last slash
     166 i = len(p)

C:\Python24\lib\ in splitdrive(p)
     117 """Split a pathname into drive and path specifiers. Returns a 2-tupl
     118 "(drive,path)"; either part may be empty"""
--> 119 if p[1:2] == ':':
     120 return p[0:2], p[2:]
     121 return '', p

TypeError: unsubscriptable object

In [2]:

As a general suggestion in your case, and for other mpl/ipython users
reporting problems: always set

xmode verbose

before sending your traceback. This will generate an extremely
detailed traceback, which may contain valuable info for the
developers, thus making it more likely that they can help you. Given
how often the devs will not be able to directly reproduce the problem
(lacking your exact hardware/software/configuration combination), such
a traceback may be the only way for them to guess what's going on.

As for your specific problem, I don't know :slight_smile:




On 6/13/06, Norman Guinasso <norman@...1149...> wrote:

I can't get import pylab to work. My matplotlabrc file and some ipython
output is attached. The font manager seems to fail. Any suggestions?

C:\Python24\lib\ in splitdrive(p)
     117 """Split a pathname into drive and path specifiers. Returns
a 2-tupl
     118 "(drive,path)"; either part may be empty"""
--> 119 if p[1:2] == ':':
     120 return p[0:2], p[2:]
     121 return '', p

TypeError: unsubscriptable object