我需要在工作中的集群上构建 NumPy(我没有 root 访问权限)。我已经编译了我自己的 Python 2.7.3 版本(带有 --enable-shared),并且因为我没有 root 访问权限,所以 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
由于某种原因,它libpython2.7.so
甚至认为它位于CFLAGS
. 我什至将目录添加到LD_LIBRARY_PATH
:
gfairchild@cj-fe1 ~/code/packages/lib> echo $LD_LIBRARY_PATH
/usr/projects/infmodels/gfairchild/packages/lib:/usr/projects/infmodels/ep_packages/db-4.3.28/lib:/usr/projects/infmodels/ep_packages/boost/lib:/usr/projects/infmodels/ep_packages/log4cpp/lib:/usr/projects/infmodels/gfairchild/packages/lib:/usr/projects/infmodels/ep_packages/db-4.3.28/lib:/usr/projects/infmodels/ep_packages/boost/lib:/usr/projects/infmodels/ep_packages/log4cpp/lib:/opt/OpenMPI/openmpi-1.4.3-gcc/lib64
我该怎么做才能让它发挥作用?谢谢!