compiling numpy for python3 for AIX works but import fails

℡╲_俬逩灬. 提交于 2019-12-10 16:55:35

问题


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!!


回答1:


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



回答2:


The python you are using should supply that flag. What does python -c "import sysconfig; print(sysconfig.get_config_vars('CCSHARED'))" print? On a "normal" linux python it should print [-fPIC])



来源:https://stackoverflow.com/questions/31704639/compiling-numpy-for-python3-for-aix-works-but-import-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!