Building a Python scientific computing environment for CentOS
Build a Python Scientific Computing Environment Based on Linux CentOS
Integrated development environment of PyDev + Eclipse
Build reference blog, Linux platform Python installation and IDE development environment, http://blog.csdn.net/guoxiaojie_415/article/details/48108319
Numpy, SciPy, and Matplotlib Installation
The integrated development environment based on Python scientific computing has many basic installation packages on windows, such as Python (x, y. However, the integrated development environment for Python scientific computing in Linux is relatively small and free of charge. Therefore, this article builds an integrated environment for Python Scientific Computing Based on CentOS from scratch. This document describes how to install Numpy, SciPy, and Matplotlib as well as the problems encountered and solutions. First, let's take a look at the installation sequence between the packages and the dependent packages of Numpy, SciPy, and Matplotlib.
The figure shows that the installation of this integrated environment can be divided into Python installation, SciPy installation, and Matplotlib installation. Before installing SciPy, install Cython, Lapack, and Numpy. Before installing Matplotlib, install Freetype, Libpng, Openssl, zlib, six, setuptool, dateutil, and pyparsing. The following describes in detail the installation process of each step.
Step 1 compile and install python
Please refer to my another blog: Linux platform Python installation and IDE development environment to build, http://blog.csdn.net/guoxiaojie_415/article/details/48108319
Step 2 compile and install SciPy and install Cython
Cython official website and download link: http://cython.org/
[Plain] view plaincopyprint?
- UnzipCython-0.23.1.zip
- CdCython-0.23.1python
- Setup. pyinstall
Install Numpy
Numpy installation package download: http://sourceforge.net/projects/numpy/files/
[Plain] view plaincopyprint?
- Unzipnumpy-1.9.2
- Cdnumpy-1.9.2
- Pythonsetup. pyinstall
Install Lapack
Lapack: http://www.netlib.org/lapack/
Blas http://www.netlib.org/blas/
By default, labpack contains blas.
Note: At the beginning, I downloaded a version of 3.5. It may be because the Fortran compiler I used is too old to compile the result. So I downloaded a version of 3.4 and compiled it.
First, confirm that gfortran is installed. Download the lapack-3.4.0 zip package on the lapack website, unzip: tar zxvflapack-3.4.0.tgz. There is a make. inc. example file under the unzipped lapack-3.4.0 directory and change it to make. inc. For gfortran compilers, you do not need to modify this file. make. inc is mainly used to set compiler and compiler options. In the makefile file:
Lib: lapacklib tmglib
# Lib: blaslib variants lapacklib tmglib
Changed:
# Lib: lapacklib tmglib
Lib: blaslib variants lapacklib tmglib
Open the terminal, switch to the current directory, and enter make.
Finally, copy the liblapack. a, librefblas. a, and libtmglib. a libraries under the folder to/usr/lib.
Still failed to compile SciPy again. In desperation, I finally chose yum for installation. However, yum does not work after the new version of python is installed, and the following error occurs,
Error 1: No module named yum
Solution: the original yum is also dependent on python and the old version of python, so I will
#! /User/bin/python modified
#! /User/bin/python2.4
Yum install-y blas-devel lapack-devel atlas-devel -- nogpgcheck
Install SciPy
Official site: SciPy http://www.scipy.org/
[Plain] view plaincopyprint?
- Unzipscipy-master.zip
- Cdscipy-master
- Pythonsetup. pyinstal
Step 3 compile and install the MatplotlibMatplotlib installation manual (important reference): http://matplotlib.org/users/installing.htmlinstall freetype?libpng=openssl#plain#view plaincopyprint?
- Yuminstallfreetypefreetype-devel
- Yuminstalllibpnglibpng-devel
- Yuminstall-yopensslopenssl-devel
After the above installation is complete, you need to re-compile and install Python to install Setuptools, Six, dateutil, and pyparsingsetuptools. Download link: https://pypi.python.org/pypi/sixdateutildownload link: uninstall
Matplotlib download link: http://matplotlib.org/downloads.html
[Plain] view plaincopyprint?
- Tarzxvfmatplotlib-1.4.3.tar.gz
- Pythonsetup. pyinstall
Question 2: You can draw a picture but cannot display it. matplotlib compiled fine, but nothing shows up when I use itImportant: https://forum.suse.org.cn/viewtopic.php? F = 24 & t = 2258
Solution: the main cause of problem 2 is that the graphic library must be added for matplotlib to display the drawn image. To meet the needs of various users, matplotlib provides multiple output types of backend. You only need to apply the graphic code to frontend. There are two types of backend: one is interactive, such as "GTKAgg, pygtk, wxpython, tkinter, Qt4, macosx, etc. This type of backend can directly display images on the screen; the other is, non-interactive, such as "examples, PS, pdf, svg, png, etc. This backend supports image formats that we are familiar with, but does not support displaying images on the screen. Check the backend Mode Supported by matplotlib on the computer. You can use the following method (in IPython ):
[Plain] view plaincopyprint?
- Importmatplotlib
- Print (matplotlib. rcsetup. all_backends) <spanstyle = "white-space: pre"> </span> # print the backend supported by matplotlib
- Print (matplotlib. matplotlib_fname () # print the matplotlib configuration path
Modify the backend in matplotlib to the graphics library type supported by your system.
[Plain] view plaincopyprint?
- Backend: Enabled
Change it to one of the following options: ['gtk ', 'gtkloan', 'gtkcairo', 'macosx', 'qt4loan', 'tktwo', 'wx ', 'wxtwo ', 'cocoa', 'gtk3cairo ', 'gtk30000', 'website', 'shanghai', 'Cairo', 'emf', 'gdk', 'pdf ', 'pgf ', 'ps', 'svg ', 'template'].
This article uses Tk, so you need to install tk and tcl
Yum install tcl-devel tk-devel
After the installation is complete, you need to re-compile and install Python and Matplotlib.
Code to test whether the Plot is successful:
[Python] view plaincopyprint?
- Importnumpyasnp
- Importscipyassp
- Importmatplotlib
- Print (matplotlib. rcsetup. all_backends)
- Print (matplotlib. matplotlib_fname ())
- Importpylabaspl
- X = np. linspace (100 * np. pi)
- Pl. plot (x, np. sin (x ))
- Pl. show ()
Test results: