Search code examples
python-3.xnumpylinker-errorsaix

compiling numpy for python3 for AIX works but import fails


Has someone had success building the numpy package for AIX6.1 or 7.1?

I downloaded numpy-1.9.2.tar.gz and ran "python3 setup.py install".

After patching a few source files it compiles. However, when I try to import numpy it says:

ImportError:    0509-022 Cannot load module /python3.4/site-packages/numpy/core/multiarray.so.
       0509-187 The local-exec model was used for thread-local
                  storage, but the module is not the main program.
       0509-193 Examine the .loader section header with the
                'dump -Hv' command.

My guess is that it has got some -fPIC issues?!? I tried "CFLAGS="-fPIC" python3 setup.py install" but with the same result. Any suggestions? Thanks a lot!!


Solution

  • I tried again today and it worked. It was indeed an -fPIC issue. I found that "python3 setup.py clean" doesn't clean up all *.so files and so my previous experiments actually never re-build those. So here's what you need to do:

    (0) download the latest numpy source package and unpack it

    (1) Make sure Python.h is the first include in the following files

    numpy/core/src/multiarray/methods.c
    numpy/core/src/umath/test_rational.c.src
    numpy/core/src/umath/operand_flag_test.c.src
    

    The following don't have include Python.h at all and need to have for them to compile:

    numpy/core/src/npysort/heapsort.c.src
    numpy/core/src/npysort/quicksort.c.src
    numpy/core/src/npysort/mergesort.c.src
    

    (2)

    export CC="gcc -fPIC"
    

    (3)

    python3 setup.py build
    

    (4)

    python3 setup.py install