0

After much effort, I've finally got matplotlib, and all its dependencies, working harmoniously on Snow Leopard 10.6.8. I'd now like to tweak its configuration slightly to allow me to use my 32-bit installation of wxPython as its backend. The problem is that numpy (required by matplotlib) won't import when I use my 32-bit installation of Python 2.7.3 (python.org version). Googling for an hour or so has led me to believe that numpy can be built and installed as 32-bit by specifying CFLAGS and LDFLAGS inconjunction with setup.py. I'm not clear on what these flags do, and not surprisingly I've had no success using them. This is what I tried from within the downloaded numpy folder:

$ CLFLAGS=-m32 LDFLAGS=-m32 python setup.py install

I get a few error messages, but a 64-bit compatible version of numpy does arrive in my sitepackages folder. When I use the 32-bit interpreter however I get an error:

ImportError: dynamic module does not define init function (initmultiarray)

Am I right to think I can build a 32-bit numpy?

2 Answers 2

5

I just spent a couple days looking around and pulling my hair out so I thought I'd contribute here to what I found...

I had the same problem but just setting the flags would not work for me (but this is needed indeed) ... In my case I have a seperate 32-bit version of python, so I did:

CFLAGS="-m32" LDFLAGS="-m32" /util/linux32/bin/python setup.py install --prefix=/util/science/gfortran-4.4.6/linux32/

(don't worry about my gfortran thing in the prefix, lucky me had to test different compilers.. ;) )

but then I would get an error, the last line would say: "RuntimeError: Broken toolchain: cannot link a simple C program"

but if I scrolled up I had:

gcc -pthread _configtest.o -o _configtest

_configtest.o: could not read symbols: File in wrong format

collect2: ld returned 1 exit status

_configtest.o: could not read symbols: File in wrong format

collect2: ld returned 1 exit status

failure.

removing: _configtest.c _configtest.o

and as you can see, no "-m32" flag in that call to gcc...

I tracked it back to the distutils install ; for me in there: /util/linux32/lib/python2.7/distutils/ccompiler.py

and there is probably a more elegant solution than that, like getting the cflags value directly, but I am not a python girl so not sure how.. ;) I could probably figure it out but all I care about right now is to finally install numpy in 32-bit mode.. so anyways... line 693 of this python code, I changed

runtime_library_dirs=None, debug=0, extra_preargs=None,

to

runtime_library_dirs=None, debug=0, extra_preargs=['-m32'],

(in the function link_executable ; in case you have a different version of python... )

and voila... numpy in installed succesfully on a 64-bit machine in 32-bit mode.. I assume this would work for other modules too since it is related to distutils, not numpy.. ;)

hope this can help someone in the future and save some time!

Eve-Marie

0

You could try using the free version of EPD (or the full version is free if you're in academia):

http://www.enthought.com/products/epd_free.php/

This has a 32-bit version for mac with all of the key scientific stack packages including scipy, numpy and matplotlib.

1
  • At some point in the past I think I did have a go with the EPD version, and I've also tried installing all of these packages with macports. I don't remember encountering any problems with them, but a part of the reason for trying to do them individually is to get a bit more of an idea about the nuts and bolts of installation on Unix/OS X Jun 29, 2012 at 16:22

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.