Installing the scientific computing package numpy and SciPy in Python

Source: Internet
Author: User
Tags lapack gfortran

Installing the scientific computing package numpy and SciPy in Python

In Python, the installation of most toolkit is very simple. You only need to execute the "python setup. py install" command. However, the installation process is complicated due to the dependency between SciPy and numpy scientific computing packages. Online tutorials are messy and cannot be used. After carefully studying the README and INSTALL in each package, the installation was successful. The following is a record.

System Environment:

OS: RedHat Linux 5

Python version: Python2.7.3

Gcc version: 4.1.2

 

Installation Package versions:

Scipy-0.11.0

Numpy-1.6.2

Nose-1.2.1

Lapack-3.4.2

Atlas 3.10.0

 

Dependency: the installation of scipy depends on numpy, lapack, and atlas (the latter two are linear algebra toolkit, and google is unclear ...), The running of numpy and sci test programs depends on nose. Therefore, the entire installation process must be executed in sequence. Otherwise, the installation process cannot proceed.

 

Installation steps:

1. Install nose

This installation is relatively simple. decompress the nose Installation File, enter the nose directory, and run setup. py directly:

Tar-zxvf nose-1.2.1.tar.gz

CDS nose-1.2.1

Python setup. py install

 

2. Install lapack

Because the latest version of ATLAS can be directly integrated with the lapack installation compressed file for compilation, if you only use it in python, you do not need to install lapack. Just download the compressed file: lapack-3.4.2.tgz.

 

3. Install ATLAS

This installation mainly involves configuration of some options, including configuration to 64-bit library files, location-independent and shared link libraries. Detailed configuration instructions are in the PDF file under the atlas installation package doc. Available.

The following is my installation process:

Tar-jxvf atlas3.10.0.tar.bz2

Cd ATLAS

Mkdir obj64

.. /Configure-B 64-Fa alg-fPIC-shared -- prefix =/configure the atlas installation path/atlas -- with-netlib-lapack-tarfile =/lapack install the directory where the compressed files are stored lapack-3.4.2.tgz

(Note: This configuration takes about 1 hour for Core i7 processing)

Make

(The following are some inspection procedures to ensure that there is no problem before installation)

Make check

Make time

Make install

So far, the installation of atlas is complete. However, we need to record the fortran compiler type used in the compilation process. This information should be used when numpy and scipy are installed below. Or in the directory obj64/, execute

Fgrep "F77 =" Make. inc
We can see that F77 = gfortran
Write down this compiler type gfortran.

 

4. Install numpy

The numpy and scipy installation processes must explicitly specify the type of the fortran compiler used, and be consistent with the previous compilation of atlas (in this article: gfortran), which is very important, otherwise, many functions will go wrong.

First, configure the site. cfg file under the numpy directory to specify the location of the atlas Library:

Tar-zxvf numpy-1.6.2.tar.gz

Cd numpy-1.6.2

Cp site. cfg. example site. cfg

Vim site. cfg

The configuration format is as follows:

[DEFAULT]
Library_dirs =/usr/local/lib:/atlas installation directory/atlas/lib
Include_dirs =/usr/local/include:/atlas installation directory/include

[Blas_opt]
Libraries = f77blas, cblas, atlas

[Lapack_opt]
Libraries = lapack, f77blas, cblas, atlas

[Amd]
Amd_libs = amd
[Umfpack]
Umfpack_libs = umfpack

 

Next, configure the required Fortran compiler type for numpy installation:

If the previous Fortran compiler is gfortran, run:

Python setup. py build -- fcompiler = gnu95

If the previous Fortran compiler is g77, run:

Python setup. py build -- fcompiler = gnu

 

Then execute

Python setup. py install

Installation Complete

 

5. Install scipy

Similar to installing numpy:

Tar-zxvf scipy-0.11.0.tar.gz

Cd scipy-0.11.0

Vim site. cfg

The configuration format is as follows:

[DEFAULT]
Library_dirs =/usr/local/lib:/atlas installation directory/atlas/lib
Include_dirs =/usr/local/include:/atlas installation directory/include

[Blas_opt]
Libraries = f77blas, cblas, atlas

[Lapack_opt]
Libraries = lapack, f77blas, cblas, atlas

[Amd]
Amd_libs = amd
[Umfpack]
Umfpack_libs = umfpack

 

Next, configure the required Fortran compiler type for numpy installation:

If the previous Fortran compiler is gfortran, run:

Python setup. py build -- fcompiler = gnu95

If the previous Fortran compiler is g77, run:

Python setup. py build -- fcompiler = gnu

 

Then execute

Python setup. py install

Installation Complete

 

Then you can run the corresponding test program in python:

Python

>>> Import nose

>>> Import numpy

>>> Import scipy

>>> Numpy. test ('full ')

Wait ....

>>> Scipy. test ('full ')

The entire installation process ends.

-------------------------------------- Split line --------------------------------------

Install Python3.4 on CentOS source code

Python core programming version 2. (Wesley J. Chun). [Chinese version of hd pdf]

Python development technology details. (Zhou Wei, Zong Jie). [hd PDF scan version + book guide video + code]

Obtain Linux information using a Python script

Build a desktop algorithm transaction research environment using Python in Ubuntu

A Brief History of Python Development

Python details: click here
Python: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.