【问题标题】:compiling numpy for python3 for AIX works but import fails为 AIX 的 python3 编译 numpy 工作但导入失败
【发布时间】:2015-10-20 16:21:07
【问题描述】:

有人成功地为 AIX6.1 或 7.1 构建了 numpy 包吗?

我下载了 numpy-1.9.2.tar.gz 并运行了“python3 setup.py install”。

patching a few source files 之后编译。但是,当我尝试导入 numpy 时,它会说:

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.

我的猜测是它有一些-fPIC 问题?!?我尝试了 "CFLAGS="-fPIC" python3 setup.py install" 但结果相同。有什么建议?非常感谢!!

【问题讨论】:

    标签: python-3.x numpy linker-errors aix


    【解决方案1】:

    我今天又试了一次,它成功了。这确实是一个 -fPIC 问题。我发现“python3 setup.py clean”并没有清理所有 *.so 文件,所以我之前的实验实际上从未重新构建这些文件。 所以这就是你需要做的:

    (0)下载最新的numpy源码包并解压

    (1) 确保 Python.h 是以下文件中的第一个包含

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

    以下内容根本没有包含 Python.h,需要它们才能编译:

    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】:

      您正在使用的 python 应该提供该标志。 python -c "import sysconfig; print(sysconfig.get_config_vars('CCSHARED'))" 打印什么?在“正常”的 linux python 上,它应该打印 [-fPIC])

      【讨论】:

        猜你喜欢
        • 2013-01-30
        • 1970-01-01
        • 1970-01-01
        • 2012-06-03
        • 1970-01-01
        • 2021-10-07
        • 2021-03-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多