From: Larry M. <Lar...@na...> - 2005-02-02 00:06:28
|
Chris, An alternative way to get freetype, libpng and zlib for OS X is to use the the i-Installer (http://ii2.sourceforge.net/) distribution application. It is primarily for TeX on OS X, but it provides several other useful binaries for OS X. Larry On Feb 1, 2005, at 3:50 PM, Chris Barker wrote: > Hi all, > > I just got matplotlib working on my box, so I thought I'd post this, > so that it will be in the archives, and because I'd like others to try > it and let me know if it doesn't work for you. > > > One question for the knowledgeable folks here: > > I have /usr/include/zlib.h on my system, but I have no idea where I > got it. I do know that it isn't on other systems in my office without > the dev tools. Did it come with the dev tools, or something else I > installed? > > Anyway, here's what worked for me: > > Installing matplotlib on OS-X (10.3.7) > > Here are my notes as to what it took to get matplotlib (0.71) > installed and working on OS-X. I have so far kept a fink-free system, > so that's what I've done here as well. I use it with the AGG back end > for generating images for a web site, and hopefully with the wx > backend for interactive use and embedding in wx Applications. > > 1) Requirements: > ------------------------------------------- > According to the matplotlib install docs > (http://matplotlib.sourceforge.net/installing.html), you need the > following: > > freetype (>= 2.1.7) > libpng > zlib > > Personally, I've been avoiding Fink, as it doesn't seem to play well > with the rest of OS-X, including the Apple supplied Python, so I've > looked elsewhere for these libs. > > a) Freetype: > I seem to have it in: > > /usr/X11R6/include/freetype2 > > I don't think I installed it myself, so it probably came with Apple's > X11, Which I did install. > > However, I seemed to be having problems with that version, so I > looked, and it seems to be: > > libfreetype.6.3.dylib > > Given that freetype2 is currently at version 2.1.9, I have no idea > what to make of that! So off to sourceforge to get a new freetype: > > http://freetype.sourceforge.net/index2.html > > where I got: > > freetype-2.1.9.tar.gz > > Following the instructions in docs/INSTALL.UNX: > > $ ./configure > $ make > $ sudo make install > > That puts it in /usr/local/..., which is a good place for it. > > b) zlib: > I have: > /usr/include/zlib.h > > I don't know where I might have gotten it, but there it is. > > NOTE: I checked on another system in my office, and it doesn't have > zlib. It also doesn't have any developer tools installed, so you > couldn't build anything on it anyway. If zlib comes with XCode tools, > anyone who can build should have it. It also may have come with some > other package I've installed, but I have no idea what. Let me know if > you know. > > c) libpng: > This, I didn't have on my system, except inside the wxWidgets source > tree, so I went looking for it. > > Note that you need zlib to compile libpng, so make sure you have that > first. > > I did a google search for "libpng OS-X". I found: > > http://www.libpng.org/pub/png/pngcode.html > > Which led me to the libpng sourceforge site. > > From there I downloaded: > > libpng-1.2.8.tar.gz > > unpacked it, and opened a terminal in the libpng-1.2.8 directory, and > did: > > $ cp scripts/makefile.darwin ./makefile > > (note that according to the INSTALL, there is supposed to be a > makefile.macosx, but it wasn't there) > > I took a look in the makefile, and found: > > ZLIBLIB=/usr/local/lib > ZLIBINC=/usr/local/include > > Which is not where zlib is on my system. However, while I can find > zlib.h, I couldn't fine the actual lib, so I tried make without > changing anything. > > $ make > > Which seemed to work fine. zlib must be installed in a standard > location, and gcc found it. > > $ sudo make install > > to install the lib into /usr/local/ (this was specified in the > makefile, and it's a good place for it) > > $ make test > and > $ ./pngtest pngnow.png > > Which both seemed to pass. > > d) Numeric or numarray: > > I already have Numeric installed, from Bob Ippolito's PIMP (MacPython > Package Manager) repostitory. (www.undefined.org/python) > > 2) Building matplotlib > --------------------------------------------------------- > First, I took a look at the matplotlib setup.py. It had "auto" for the > back-end flags, so I thought I would give it a try that way: > > $python setup.py build > > That worked! > $ sudo python setup.py install > > 4) And now to test! > > $python > > >>> import pylab > Could not open font file /Library/Fonts/NISC18030.ttf > No module named pygtk > PyGTK version 1.99.16 or greater is required to run the GTK Matplotlib > backends > > This turns out to be because the matlabrc file sets the GTKAgg back > end as the default. You have two choices. > > 1) you can set the back end before importing pylab. > >>> import matplotlib > >>> matplotlib.use('Agg') > >>> import pylab > > This works fine > > 2) Edit the matplotlibrc file. I found it in: > /System/Library/Frameworks/Python.framework/Versions/2.3/share/ > matplotlib/.matplotlibrc > > Change the line: > backend : GTKAgg # the default backend > to > backend : Agg # the default backend > > And you're all set to make images for the web, etc. > > I'm going to leave getting it to work with wxPython for another day. > > -Chris > > > -- > Christopher Barker, Ph.D. > Oceanographer > > NOAA/OR&R/HAZMAT (206) 526-6959 voice > 7600 Sand Point Way NE (206) 526-6329 fax > Seattle, WA 98115 (206) 526-6317 main reception > > Chr...@no... > _______________________________________________ > Pythonmac-SIG maillist - Pyt...@py... > http://mail.python.org/mailman/listinfo/pythonmac-sig > > Larry Meyn Aerospace Operations Modeling Office M/S 210-10 NASA Ames Research Center Moffett Field, CA 94035-1000 E-mail: Lar...@na... Phone: (650) 604-5038 Fax: (650) 604-0222 E-Fax: (425) 944-5526 sent via e-mail Larry Meyn Aerospace Operations Modeling Office M/S 210-10 NASA Ames Research Center Moffett Field, CA 94035-1000 E-mail: Lar...@na... Phone: (650) 604-5038 Fax: (650) 604-0222 E-Fax: (425) 944-5526 sent via e-mail |