加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python-3.x – 为AIX编译python3的numpy工作但导入失败

发布时间:2020-12-20 13:51:38 所属栏目:Python 来源:网络整理
导读:有人成功构建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/
有人成功构建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”,但结果相同.有什么建议?非常感谢!!

解决方法

我今天再次尝试,它有效.这确实是一个-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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读