Python ImportError with backend_wx2.8 and wxPython when using Matplotlib

For many months, since I upgraded to Snow Leopard (10.6), I’ve had the following error when trying to import matplotlib. When I issued the command “import pylab” or “from pylab import *” in iPython, Python, or any other tool that uses the Python shell, I got the following error:

ImportError: Matplotlib backend_wx and backend_wxagg require wxPython >=2.8

Well, after poking around this problem for the thousandth time, I finally fixed it for good. I did this by removing my ~/.matplotlib/matplotlibrc file. In this file, there was only one line:

backend : WXAgg

which I removed (and since it was the only line, I just removed the file). Now the error is gone, and matplotlib imports just fine, meaning that I can use it in any Python shell, including Sage.

Just thought I’d post this up in case any other Python/Snow Leopard users are having trouble.