Linux

numpy, scipy, matplotlib설치하기 centos 5.5

Naan 2013. 5. 28. 13:22
320x100

centos 5.5 버전에는 python 버전이 2.4 버전이다 

yum으론 2.6 이상 버전으로 업그레이드 불가능하다.

아래와 같이 진행하면 된다.


[root@localhost tmp]# wget python.org/ftp/python/2.6.6/Python-2.6.6.tgz

--2013-05-28 11:21:09--  http://python.org/ftp/python/2.6.6/Python-2.6.6.tgz

Resolving python.org... 82.94.164.162, 2001:888:2000:d::a2

Connecting to python.org|82.94.164.162|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 13318547 (13M) [application/x-tar]

Saving to: `Python-2.6.6.tgz.1'

100%[======================================================================================>] 13,318,547  3.45M/s   in 6.6s

2013-05-28 11:21:17 (1.92 MB/s) - `Python-2.6.6.tgz.1' saved [13318547/13318547]

[root@localhost tmp]# tar -xvf Python-2.6.6.tgz
[root@localhost tmp]#./configure && make && make instal
설치 완료
[root@localhost Python-2.6.6]# python -V
Python 2.6.6
2.6.6 버전 설치 완료

자 이제는 numpy 설치
설치를 하기위해서는 소스 파일이 필요하다(LAPACK, BLAS)
LAPACK: http://www.netlib.org/lapack/ 
BLAS: http://www.netlib.org/blas/

blas.tgz


lapack-3.4.2.tgz


numpy-1.7.1.tar.gz


[root@localhost tmp]# tar -xvf blas.tgz

[root@localhost tmp]# tar -xvf lapack-3.4.2.tgz
[root@localhost tmp]# tar -xvf numpy-1.7.1.tar.gz
[root@localhost tmp]# cd numpy-1.7.1.tar.gz
[root@localhost numpy-1.7.1]# cp site.cfg.example site.cfg
[root@localhost numpy-1.7.1]# vi site.cfg

[DEFAULT] 
src_dirs = /tmp/BLAS/:/tmp/lapack-3.4.2/ 
[blas_opt] 
libraries = f77blas, cblas 
[lapack_opt] 
libraries = lapack, f77blas, cblas

위 내용 추가 src_dirs 는 절대 경로 이다.

[root@localhost numpy-1.7.1]#python setup.py build --fcompiler=gnu95
설치 다 끝나면
[root@localhost numpy-1.7.1]#python setup.py install --prefix=~/.local
설치 완료



다음은 scipy 설치


scipy-0.10.0.tar.gz


[root@localhost tmp]#tar -xvf scipy-0.10.0.tar.gz

[root@localhost tmp]#cd scipy-0.10.0.tar.gz

[root@localhost scipy-0.10.0]#python setup.py build --fcompiler=gnu95

[root@localhost scipy-0.10.0]#python setup.py install --prefix=~/.local

설치 완료

[error1] 

설치하다가 블라 블라 하면서

Traceback (most recent call last):

  File "setup.py", line 165, in <module>

    setup_package()

  File "setup.py", line 161, in setup_package

    configuration=configuration)

  File "/root/.local/lib/python2.6/site-packages/numpy/distutils/core.py", line 152, in setup

    config = configuration()

  File "setup.py", line 136, in configuration

    config.add_subpackage('scipy')

  File "/root/.local/lib/python2.6/site-packages/numpy/distutils/misc_util.py", line 1003, in add_subpackage

    caller_level = 2)

  File "/root/.local/lib/python2.6/site-packages/numpy/distutils/misc_util.py", line 972, in get_subpackage

    caller_level = caller_level + 1)

  File "/root/.local/lib/python2.6/site-packages/numpy/distutils/misc_util.py", line 909, in _get_configuration_from_setup_py

    config = setup_module.configuration(*args)

  File "scipy/setup.py", line 13, in configuration

    config.add_subpackage('linalg')

  File "/root/.local/lib/python2.6/site-packages/numpy/distutils/misc_util.py", line 1003, in add_subpackage

    caller_level = 2)

  File "/root/.local/lib/python2.6/site-packages/numpy/distutils/misc_util.py", line 972, in get_subpackage

    caller_level = caller_level + 1)

  File "/root/.local/lib/python2.6/site-packages/numpy/distutils/misc_util.py", line 909, in _get_configuration_from_setup_py

    config = setup_module.configuration(*args)

  File "scipy/linalg/setup.py", line 30, in configuration

    if needs_g77_abi_wrapper(lapack_opt):

  File "/tmp/scipy-0.12.0/scipy/_build_utils/_fortran.py", line 29, in needs_g77_abi_wrapper

    elif _uses_mkl(info) and sys.platform == "darwin":

  File "/tmp/scipy-0.12.0/scipy/_build_utils/_fortran.py", line 19, in _uses_mkl

    if r_mkl.search(library):

TypeError: expected string or buffer

하면서 에러가 뜬다.

위와 같은 경우 지원 버전이 안맞아서 그렇다 (0.12 버전은 설치가 안된다)

[error2]
설치 경로 관련 에러가 뜬다면
아까 numpy 설정했던 site.cfg 설정파일을 복사해서 사용하면 된다.


마지막으로 matplotlib


[root@localhost tmp]# tar -xvf matplotlib-1.2.0.tar.gz
[root@localhost tmp]# cd matplotlib-1.2.0
[root@localhost matplotlib-1.2.0]# python setup.py build
[root@localhost matplotlib-1.2.0]# python setup.py install

설치 완료






320x100