By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

GD/gdmodule on Win XP

P: n/a
Hi All,

I'm trying to setup matplotlib (http://matplotlib.sourceforge.net/) in
a Win XP box.

I have two questions:

1. How do I install the GD Lib (http://www.boutell.com/gd)? The zip
contains a compiled dll. Is it enough to put it in /Windows/System32?

2. The python interface to GD at
http://newcenturycomputers.net/projects/gdmodule.html (gdmodule) has a
setup.py script for Linux systems. Is there any windows/multiplatfor
version? I tried to hack it including the /Windows/systm32 dir in the
libdirs variables and renaming the dll file to gd.dll, but the script
doesn't work either.

Thank you in advance.

Ed.
Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
>>>>> "Eduardo" == Eduardo Elgueta <ee******@navix.cl> writes:

Eduardo> Hi All, I'm trying to setup matplotlib
Eduardo> (http://matplotlib.sourceforge.net/) in a Win XP box.

gdmodule is difficult to install on windows (as you've discovered).
Fortunately, Stefan Kuzminski figured this out and built a statically
linked gd module - no need to download gd lib or freetype, etc. Here
are the compile notes he posted to the matplotlib-users mailing list

http://sourceforge.net/mailarchive/m...msg_id=7064914

and here is a link to the dll; just put this in your site-packages dir.

http://matplotlib.sourceforge.net/gd/_gd.dll

You will also need to place gd.py from the gdmodule-0.51 distro in
site-packages. After that you should be able to do
python
import gd


IMPORTANT - I've been doing a lot of development on the gd backend of
late and the latest version of matplotlib requires a patched version
of gdmodule (which will become included in the standard gdmodule at
the next release). So the DLL linked above *will not* work with
matplotlib-0.50. Thus you will need to either:

* downgrade to matplotlib-0.42.2 -
http://sourceforge.net/project/showf...group_id=80706

* build the patched gdmodule using
http://matplotlib.sourceforge.net/gd/_gdmodule.c. If you do
this, you can take advantage of the improvements made in the gd
backend subsequent to 0.42.2. Please mail me a copy of the DLL
if you succeed with any compile notes.

Of course you still need to the prerequisites described on
http://matplotlib.sourceforge.net/backends.html#GD, but gdmodule is
definitely the tough nut to crack on win32.

I haven't built fonttools for win32 in some time, so if someone else
can pipe in and share their insights I'd be happy. I found the TTX
installer on the sourceforge site, but this doesn't seem to provide
the python fontools package.

With the prereqs installed, you can test your setup with

import matplotlib
matplotlib.use('GD')
from matplotlib.matlab import *
plot([1,2,3])
savefig('gdtest')

Good luck!
John Hunter

Jul 18 '05 #2

P: n/a
John,

Thank you very much for such a complete answer.

I'll try it and let you now if I succeed building the patched gdmodule.

Best regards,

Ed.

<cita quien="John Hunter">
>> "Eduardo" == Eduardo Elgueta <ee******@navix.cl> writes:


Eduardo> Hi All, I'm trying to setup matplotlib
Eduardo> (http://matplotlib.sourceforge.net/) in a Win XP box.

gdmodule is difficult to install on windows (as you've discovered).
Fortunately, Stefan Kuzminski figured this out and built a statically
linked gd module - no need to download gd lib or freetype, etc. Here
are the compile notes he posted to the matplotlib-users mailing list

http://sourceforge.net/mailarchive/m...msg_id=7064914

and here is a link to the dll; just put this in your site-packages dir..

http://matplotlib.sourceforge.net/gd/_gd.dll

You will also need to place gd.py from the gdmodule-0.51 distro in
site-packages. After that you should be able to do
> python
>>> import gd


IMPORTANT - I've been doing a lot of development on the gd backend of
late and the latest version of matplotlib requires a patched version
of gdmodule (which will become included in the standard gdmodule at
the next release). So the DLL linked above *will not* work with
matplotlib-0.50. Thus you will need to either:

* downgrade to matplotlib-0.42.2 -
http://sourceforge.net/project/showf...group_id=80706

* build the patched gdmodule using
http://matplotlib.sourceforge.net/gd/_gdmodule.c. If you do
this, you can take advantage of the improvements made in the gd
backend subsequent to 0.42.2. Please mail me a copy of the DLL
if you succeed with any compile notes.

Of course you still need to the prerequisites described on
http://matplotlib.sourceforge.net/backends.html#GD, but gdmodule is
definitely the tough nut to crack on win32.

I haven't built fonttools for win32 in some time, so if someone else
can pipe in and share their insights I'd be happy. I found the TTX
installer on the sourceforge site, but this doesn't seem to provide
the python fontools package.

With the prereqs installed, you can test your setup with

import matplotlib
matplotlib.use('GD')
from matplotlib.matlab import *
plot([1,2,3])
savefig('gdtest')

Good luck!
John Hunter

--
Eduardo Elgueta
Senior Consultant
Navix

correo/email: ee******@navix.cl
teléfono/phone: +56 (2) 209-8905
celular/mobile: +56 (9) 821-0033
web: www.navix.cl

Av. Pedro de Valdivia 555 Of. 216
Providencia 750-0913
Santiago, Chile

Jul 18 '05 #3

P: n/a
>>>>> "Eduardo" == Eduardo Elgueta <ee******@navix.cl> writes:

Eduardo> John, Thank you very much for such a complete answer.

Eduardo> I'll try it and let you now if I succeed building the
Eduardo> patched gdmodule.

That would be great. In the mean time, I have two more pieces of
advice

There is a strange bug that Stefan discovered when saving some images
on win32. You need to change the line in
matplotlib.backends.backend_gd.print_figure from

im.writePng( file(filename, 'wb') )
to
im.writePng( filename )

Also, if you need windows installers for fonttools, I built them last
night for python2.2 and python2.3. Let me know and I'll send you one.

I'd like to add a section 'building GD on win32' to the website, so
let me know if you have anything to add to that.

JDH
Jul 18 '05 #4

P: n/a
I just went through a similar process in getting a native 2.3 version
of the jpgraph charting library to build on windows. While not
exactly, the same, I hope these notes will help you out.

Things build fairly straightforward using MINGW and MINSYS to build
the python extentions. The process is went like this:

Install MINGW and MINSYS

Run dll tool on Python23 to make libpython23.a:
[from: http://sebsauvage.net/python/mingw.html)
pexports python23.dll > python23.def
(get it from http://starship.python.net/crew/kern...orts-0.42h.zip)
dlltool --dllname python23.dll --def python23.def --output-lib
libpython23.a
Copy libpython23.a to c:\python23\libs\
]
Then for each module, one at a time, perform the following sequence:

Untar the source archive.
Open a minsys window and do a compile. Config generally works when
they have them. Other changes are to add the python include dir to
CFLAGS and to add python23 to the linker libs and the python 'libs'
dir to the LD library path.
Copy all the resulting "lib*.a" files to C:\mingw\lib (adjusting for
your installation of course!).
Inspect the makefile install target to determine what ".h" files
should be copied. Copy these over to c:\mingw\include.
For python modules, copy the .pyd files to your python home
\lib\site-packages directory.

After some trial and error, I found I had to build the modules in the
following order:

freetype-2.1.5
zlib-1.2.1
libpng-1.2.5
jpeg-6b
gd-1.8.4
gdmodule-0.26
jpgraph-1.5.3

I'm sure there's room for improvement, for example make install might
have worked. I didn't really care about the amount of manual copying
in this process as I just wanted the resulting python library.
Jul 18 '05 #5

P: n/a
John,

Ok. See you around.

Ed.

<cita quien="John Hunter">
>> "Eduardo" == Eduardo Elgueta <ee******@navix.cl> writes:


Eduardo> John, Thank you very much for such a complete answer.

Eduardo> I'll try it and let you now if I succeed building the
Eduardo> patched gdmodule.

That would be great. In the mean time, I have two more pieces of
advice

There is a strange bug that Stefan discovered when saving some images
on win32. You need to change the line in
matplotlib.backends.backend_gd.print_figure from

im.writePng( file(filename, 'wb') )
to
im.writePng( filename )

Also, if you need windows installers for fonttools, I built them last
night for python2.2 and python2.3. Let me know and I'll send you one.

I'd like to add a section 'building GD on win32' to the website, so
let me know if you have anything to add to that.

JDH

--
Eduardo Elgueta
Senior Consultant
Navix

correo/email: ee******@navix.cl
teléfono/phone: +56 (2) 209-8905
celular/mobile: +56 (9) 821-0033
web: www.navix.cl

Av. Pedro de Valdivia 555 Of. 216
Providencia 750-0913
Santiago, Chile

Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.