Install numpy, scipy, and matplotlib in centos6.4

Source: Internet
Author: User
Tags lapack install matplotlib gfortran

Installation Package versions:

Scipy-0.11.0

Numpy-1.6.2

Nose-1.2.1

Lapack-3.4.2

# Atlas-3.10.0 (http://pkgs.fedoraproject.org/repo/pkgs/atlas)

 

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.

sudo yum -y install gcc gcc-c++ numpy python-devel scipysudo pip install nosesudo pip install numpy

There are many problems when installing scipy:

1. Blas (http://www.netlib.org/Blas/) libraries not found.

Directories to search for the libraries can be specified in

Numpy/distutils/site. cfg file (Section [Blas]) or by setting

The BLAs environment variable.

Blas not found

Solution: Yum install blas-devel

2.

There is no Blas error.

LAPACK Error

Solution: Yum install LAPACK-devel

 

Then, CD scipy-0.13.3 & sudo Python setup. py install

Compiled successfully

Then the installation was successful.

Check that GCC-gfortran, Blas-devel, and LAPACK-devel must be installed before numpy is installed.

No gcc-gfortran error encountered. Maybe it was installed on the previous machine.

Finally, install matplotlib ....

Required numpy, libpng 1.2 (or later), 'freetype '1.4 (or later), 'dateutil' 1.1 or later, 'pyparsing'

Sudo-E/usr/local/bin/pip3 install Python-dateutilsudo-E/usr/local/bin/pip3 install pyparsingwget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gzwget plugin.

 

 

Compilation and installation are fine.

But after the installation, the import is okay.

However, the show () method is used for image mirroring.

Never responding

Check the software version for the require section of the install file under the setup. py directory.

No problem

It is also said that matplotlib will automatically check the backend environment.

Tkinter is also available in centos.

Later

Yum install *-TK * install two software packages ending with-TK

Yum install * gtk2-* install all the software starting with gtk2

Recompile and install matplotlib

Show () will show the image.

Maybe you only need to install some software.

But numpy, scipy, and matplotlib are all done well.

 

Note:

Install cblas, LAPACK, and lapacke in Linux:

1.Make sure that the gfortran compiler is installed on the machine. If not, you can useSudo apt-Get install gfortran

2.DownloadBlas,Cblas,LAPACKSource code, these source code can be found on the http://www.netlib.org, download and unzip. Here is the download link for my installation http://www.netlib.org/blas/blas.tgz http://www.netlib.org/blas/blast-forum/cblas.tgz http://www.netlib.org/lapack/lapack-3.4.2.tgz, there will be three folders after the decompression,Blas,Cblas,Lapack-3.4.2

3.Here is the specific compilation steps

1) Compile Blas, enter the BLAs folder, and execute the following commands

123 gfortran -c  -O3 *.f  # Compile all. f files to generate. O filesar rv libblas.a *.o  # Link all. O files to generate. A filessu cp libblas.a /usr/local/lib# Copy the library file to the system library directory

2) Compile cblas and enter the cblas folder. First, based on your computer platform, run a makefile in the directory. copy XXX to makefile. in, xxx indicates the computer platform. If it is Linux, makefile is used. in Linux, copy to makefile. in, and then execute the following command

 

 

123 cp ../BLAS/libblas.a  testing  # Copy the successfully compiled libblas. a In the previous step to the testing subdirectory in the cblas directory.make # Compile all directoriessudo cp lib/cblas_LINUX.a /usr/local/lib/libcblas.a # Copy the library file to the system library directory

3) Compile LAPACK and lapacke, this step is more troublesome, first of course is to enter the lapack-3.4.2 folder, and then according to the characteristics of the platform, the install directory corresponding make. inc. xxx copies a copy to the lapack-3.4.2 directory and name it make. inc. Here I copied install/make. inc. gfortran, because I use the gfortran compiler here.

Modify the lapack-3.4.2/makefile because LAPACK has been in the BLAs library, so you need to make the following changes

# Lib: lapacklib tmglib

Lib: blaslib variants lapacklig tmglib

Run the following command:

 

123456 make # Compile all LAPACK filescd lapacke # Enter the lapacke folder, which contains the lapack c language interface filemake # Compile lapackecp include/*.h /usr/local/include # Copy the header file of lapacke to the system header file directorycd .. # Return to lapack-3.4.2 directorycp *.a /usr/local/lib # Copy all generated library files to the system library directory

The header files include lapacke. H, lapacke_config.h, lapacke_mangling.h, and lapacke_mangling_with_flags.h lapacke_utils.h.

The generated library files include: liblapack. A, liblapacke. A, librefblas. A, libtmglib.

Now, cblas and LAPACK are successfully installed on your computer.

 

Test:

You can go to the http://www.netlib.org/lapack/lapacke.html to find the test code, Here lapacke official documentation, such as the following code:

12345678910111213141516171819202122232425262728 #include <stdio.h>#include <lapacke.h> int main (int argc, const char * argv[]){   double a[5*3] = {1,2,3,4,5,1,3,5,2,4,1,4,2,5,3};   double b[5*2] = {-10,12,14,16,18,-3,14,12,16,16};   lapack_int info,m,n,lda,ldb,nrhs;   int i,j;    m = 5;   n = 3;   nrhs = 2;   lda = 5;   ldb = 5;    info = LAPACKE_dgels(LAPACK_COL_MAJOR,‘N‘,m,n,nrhs,a,lda,b,ldb);    for(i=0;i<n;i++)   {      for(j=0;j<nrhs;j++)      {         printf("%lf ",b[i+ldb*j]);      }      printf("\n");   }   return(info);}

Save the appeal code as test. C. When compiling, do not forget to use gfortran. In addition, you also need to connect to the library used to compile the above Code. Use the following command:

1 gfortran test.c -llapacke -llapack -lrefblas

If compilation is successful, the installation is successful. To understand the specific meaning of this Code, go to the http://www.netlib.org/lapack/lapacke.html to view

Install numpy, scipy, and matplotlib in centos6.4

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.