Python under the scientific calculation package NumPy and scipy Installation "original"

Source: Internet
Author: User

Most toolkits under Python are easy to install, just execute the "Python setup.py Install" command. However, the installation process is more complex due to the dependence of the two scientific computing packages, scipy and NumPy. The online tutorial is confusing and doesn't work as basic. After careful study of the Readme and install in each package, the installation was finally successful. It is now recorded as follows.

System environment:

Os:redhat5

Python version: Python2.7.3

GCC version: 4.1.2

Individual installation package Versions:

scipy-0.11.0

numpy-1.6.2

nose-1.2.1

lapack-3.4.2

atlas-3.10.0

Dependencies: SciPy installation needs to rely on NumPy, Lapack, Atlas (the latter two are linear Algebra toolkit, unclear self Google ... ), and the NumPy and SCI test programs run on nose, so the entire installation process must be executed sequentially, otherwise it cannot be executed.

Installation steps:

1, installation nose

This installation is relatively simple, unzip the nose installation files, enter the nose directory, directly run setup.py can:

TAR-ZXVF nose-1.2.1.tar.gz

CD nose-1.2.1

python setup.py Install

2, installation Lapack

Since the latest version of Atlas can be compiled directly with the Lapack installation zip file, it is not necessary to install lapack if it is used only under Python. Just download the compressed file: Lapack-3.4.2.tgz can be.

3. Install Atlas

This installation is mainly about configuring options, including configuration as 64-bit library files, location-independent, and shared link libraries. Detailed configuration instructions are in the PDF file under Atlas installation package doc/. can be consulted.

Here is my installation process:

TAR-JXVF atlas3.10.0.tar.bz2

CD ATLAS

mkdir obj64

.. /configure-b 64-FA alg-fpic-shared--prefix=/Configuring the installation path for Atlas/atlas--with-netlib-lapack-tarfile=/lapack Installing compressed Files directory/ Lapack-3.4.2.tgz

(Note: This configuration time is very long, in the Core i7 processing, about 1 hours or so)

Make

(Here are some inspection procedures to ensure that there are no problems before installing)

Make check

Make Time

Make Install

At this point, the Atlas installation is complete. However, we want to record the type of Fortran compiler used in the compilation process, this information is used when installing numpy and scipy below. or under Directory obj64/, execute the

Fgrep "F77 =" make.inc
You can see F77 = Gfortran
Note This compiler type Gfortran.

4, Installation NumPy

The installation process for both NumPy and scipy explicitly indicates the type of Fortran compiler used, and it is important to be consistent with the previous compilation of Atlas (in this article: Gfortran), otherwise many functions will go wrong.

First configure the Site.cfg file in the NumPy directory to indicate 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

Configured in the following format:

[DEFAULT]
Library_dirs =/usr/local/lib:/atlas's installation directory/atlas/lib
Include_dirs =/usr/local/include:/atlas's 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 type of FORTRAN compiler required to install NumPy:

If the previously obtained Fortran compiler is Gfortran, execute:

python setup.py build--fcompiler=gnu95

If the previously obtained Fortran compiler is G77, execute:

python setup.py build--fcompiler=gnu

And then execute

python setup.py Install

Installation Complete

5, Installation SciPy

Similar to installing NumPy:

TAR-ZXVF scipy-0.11.0.tar.gz

CD scipy-0.11.0

Vim site.cfg

Configured in the following format:

[DEFAULT]
Library_dirs =/usr/local/lib:/atlas's installation directory/atlas/lib
Include_dirs =/usr/local/include:/atlas's 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 type of FORTRAN compiler required to install NumPy:

If the previously obtained Fortran compiler is Gfortran, execute:

python setup.py build--fcompiler=gnu95

If the previously obtained Fortran compiler is G77, execute:

python setup.py build--fcompiler=gnu

And then execute

python setup.py Install

Installation Complete

You can then execute the appropriate test program under Python:

python

>>> Import Nose

>>> Import NumPy

>>> Import scipy

>>> numpy.test (' full ')

Wait....

>>> scipy.test (' full ')

Here, the entire installation process is complete.

Python under the scientific calculation package NumPy and scipy Installation "original"

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.