生成NumPy时出错:找不到lpython2.7

2024-10-01 18:35:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要在这里的集群上构建NumPy(我没有根访问权限)。我已经编译了我自己的Python2.7.3版本(使用--enable shared),而且由于我没有根访问权限,所以Python位于非标准位置。不过,我在编译NumPy时遇到了一个问题。我得到的是:

gfairchild@cj-fe1 ~/code/packages/src/numpy-1.6.2> export CFLAGS="-L/usr/projects/infmodels/gfairchild/packages/lib"
gfairchild@cj-fe1 ~/code/packages/src/numpy-1.6.2> python setup.py build --fcompiler=gnu95
...
...
...
compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/include -I/usr/projects/infmodels/gfairchild/packages/stow/Python-2.7.3/include/python2.7 -c'
gcc: _configtest.c
gcc -pthread _configtest.o -o _configtest
_configtest
failure.
removing: _configtest.c _configtest.o _configtest
building data_files sources
build_src: building npy-pkg config files
running build_py
copying numpy/version.py -> build/lib.linux-x86_64-2.7/numpy
copying build/src.linux-x86_64-2.7/numpy/__config__.py -> build/lib.linux-x86_64-2.7/numpy
copying build/src.linux-x86_64-2.7/numpy/distutils/__config__.py -> build/lib.linux-x86_64-2.7/numpy/distutils
running build_clib
customize UnixCCompiler
customize UnixCCompiler using build_clib
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'numpy.linalg.lapack_lite' extension
compiling C sources
C compiler: gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -L/usr/projects/infmodels/gfairchild/packages/lib -fPIC

compile options: '-DATLAS_INFO="\"3.6.0\"" -I/usr/include/atlas -Inumpy/core/include -Ibuild/src.linux-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/include -I/usr/projects/infmodels/gfairchild/packages/stow/Python-2.7.3/include/python2.7 -Ibuild/src.linux-x86_64-2.7/numpy/core/src/multiarray -Ibuild/src.linux-x86_64-2.7/numpy/core/src/umath -c'
gcc: numpy/linalg/lapack_litemodule.c
gcc: numpy/linalg/python_xerbla.c
/usr/bin/gfortran -Wall -Wall -shared build/temp.linux-x86_64-2.7/numpy/linalg/lapack_litemodule.o build/temp.linux-x86_64-2.7/numpy/linalg/python_xerbla.o -L/usr/lib64/atlas -L. -Lbuild/temp.linux-x86_64-2.7 -llapack -lf77blas -lcblas -latlas -lpython2.7 -lgfortran -o build/lib.linux-x86_64-2.7/numpy/linalg/lapack_lite.so
/usr/bin/ld: cannot find -lpython2.7
collect2: ld returned 1 exit status
/usr/bin/ld: cannot find -lpython2.7collect2: ld returned 1 exit status
error: Command "/usr/bin/gfortran -Wall -Wall -shared build/temp.linux-x86_64-2.7/numpy/linalg/lapack_litemodule.o build/temp.linux-x86_64-2.7/numpy/linalg/python_xerbla.o -L/usr/lib64/atlas -L. -Lbuild/temp.linux-x86_64-2.7 -llapack -lf77blas -lcblas -latlas -lpython2.7 -lgfortran -o build/lib.linux-x86_64-2.7/numpy/linalg/lapack_lite.so" failed with exit status 1

由于某些原因,即使它在CFLAGS指定的目录中,也找不到{}。我甚至把目录添加到LD_LIBRARY_PATH

^{pr2}$

我该怎么做才能让这个工作起来?谢谢!在


Tags: corebuildsrcnumpyincludelinuxlibpackages
2条回答

我认为您需要将-L/some/path选项放入LDFLAGS,而不是CFLAGSCFLAGS[通常]传递给编译器,LDFLAGS[通常]传递给链接器,而您看到的是链接器错误:)

顺便说一下,在这种情况下,错误出现在Fortran编译器错误之后。您也可以尝试在FCFLAGS中提供-L(即使它不是真正的编译器,而是链接器标志。。这只是为了以防万一你真的非常渴望黑客攻击)。在

我刚修好了!在numpy-1.6.2目录中,我看到一个名为site.cfg.example的文件。从里面看,我看到您可以指定库和包含目录。我只创建了一个名为site.cfg的文件,其内容如下:

[DEFAULT]
library_dirs = /usr/projects/infmodels/gfairchild/packages/lib:/usr/local/lib
include_dirs = /usr/projects/infmodels/gfairchild/packages/include:/usr/local/include

这就是它完成建造所需的全部。m01的解决方案(添加LDFLAGS的路径)让我走得更远,但仍然出错了。site.cfg文件允许它完成生成。在

相关问题 更多 >

    热门问题