0

I am trying to install Matplotlib for Python on Mac. First it threw an error stating that dateutil is not installed. After I installed that, I got the error message that pyparsing should be installed first. So I started to download pyparsing and tried to install it, as per the instructions at http://pyparsing.wikispaces.com/Download+and+Installation. However, I am getting the following error message:

enter image description here

Any help regarding this? Plus, what else do I need to install Matplotlib? I have been trying for hours, first I was getting an error message like gcc is required when I was trying to download through pip. Then I left that and installed it through the pkg file. It succeeded, but when I try to import matplotlib I get these messages like dateutil required, then pyparsing required..

Update:

Following the answer below, I installed a lower version of pyparsing compatible with Python 2.7, and now import matplotlib works. However, still when I am trying to get a dispersion plot from NLTK, I am getting a matplotlib missing error:

enter image description here

Specifically, although import matplotlib works fine and throws no error, when I try something like import matplotlib.pyplot as pl I get this error:

enter image description here

SexyBeast
  • 7,913
  • 28
  • 108
  • 196

1 Answers1

1

The error you're seeing is a Python 3 language feature (nonlocal), and you must be using Python 2 to run the setup script. You'll need a version of PyParsing that is 2.x compatible to install instead (assuming you're trying to use Python 2.x).

If you want to build / install python packages that have C-extensions, you should install Xcode, and then the command line tools (used to be a separate download, now it is available in-program from a preference pane). Then you'll have a compiler installed, which is needed to build any python packages that require c-extensions to be compiled.

You can then use pip to install your package and its dependencies automatically, and build the required c-extensions.

Alternatively, you could install the Enthought Python Distribution, which comes with matplotlib, numpy, scipy, and other scientific computing packages pre-built. This would be a different python interpreter / install area on your computer, which you would need to use instead of the version Apple ships with OS X.

Matt Anderson
  • 19,311
  • 11
  • 41
  • 57
  • Thanks dude. That kind of helped, though my problem is not yet fully solved. Please see the update in question.. – SexyBeast Jun 01 '13 at 17:33
  • And as for the Enthought link you shared, I downloaded `Canopy`. It comes pre-installed with `Numpy` and `Scipy` all right, but neither `NLTK` nor `mathplotlib`.. – SexyBeast Jun 01 '13 at 17:44
  • That's odd. The explicitly list matplotlib in their product description here: https://www.enthought.com/products/epd/free/ – Matt Anderson Jun 01 '13 at 17:52