2012-11-27 72 views
0

我需要一個集羣在這裏工作構建NumPy的(我沒有root訪問權限)。我編譯我自己的Python 2.7.3版本(加上--enable-共享),因爲我沒有root訪問權限,巨蟒生活在一個非標準的位置。不過,我有一個編譯NumPy的問題。這就是我得到:誤差建設與NumPy:找不到-lpython2.7

[email protected] ~/code/packages/src/numpy-1.6.2> export CFLAGS="-L/usr/projects/infmodels/gfairchild/packages/lib" 
[email protected] ~/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

[email protected] ~/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 

我能做些什麼來得到這個工作?謝謝!

回答

2

我只定了!查看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文件允許它完成構建。

1

我認爲您需要將-L/some/path選項設置爲LDFLAGS而不是CFLAGSCFLAGS是[通常]傳遞到編譯器,LDFLAGS [通常]的連接器和你正在尋找一個鏈接錯誤:)

順便說一句,在這種情況下只是一個Fortran編譯錯誤後出現的錯誤。您可以嘗試提供-LFCFLAGS以及(即使它不是一個真正的編譯器,而是一個連接標誌..這是以防萬一你得到一個黑客真的絕望)。

+0

謝謝!不過,我實際上只是修正了它。我只是添加了我的解決方案作爲答案。 – Geoff