< go from:http://www.noanylove.com/2014/10/centos-6-5-sheng-ji-python-he-an-zhuang-ipython/> to self-employed. To do a backup
Before using CentOS 5.8, I wrote a "Python upgrade to CentOS". Later replaced with CentOS 6.5, the system comes with the Python version is 2.6.6, do not bother to toss. Recently installed Ipython, only to find that Ipython 2.3 requires Python 2.7 or greater than or equal to 3.3, as shown in. Only Python has been upgraded.
Figure one: Installation Ipython requirements
Compiled tools such as GCC have been installed. The system comes with Python version and installation location two as shown:
Figure two: The system comes with Python installation information Installation steps
1. Install the Development library file
Compiling python is sufficient as long as there is a GCC compiler, but some extensions require additional libraries, otherwise some Python modules will not be available (such as Python's zlib module requires the Zlib-devel,ssl module needs to be Openssl-devel). Users can selectively install these extensions as needed. Here we install the zlib, SSL, and Sqlite3 library files.
yum install zlib-devel openssl-devel sqlite-devel
2. Download Python
Currently the latest version is 2.7.8.
wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgztar zxvf Python-2.7.8.tgz
3. Compile and install
For ease of administration, Python is installed under the/usr/local/python path.
cd Python-2.7.8 ./configure --prefix=/usr/local/pythonmakemake install
4. The replacement system comes with Python
After installation, the Python 2.7.8 executable file is located in/usr/local/python/bin. Rename the system's Python to python2.6 first, and then create a new Python-to-/usr/bin symbolic link.
mv /usr/bin/python /usr/bin/python2.6 #其实不要这句也行,加上了预防万一ln -sf /usr/local/python/bin/python2.7 /usr/bin/python
Again python --version , you can see that the version is already 2.7.8, as shown in three.
Figure three: Successful installation of Python 2.7.8
5. Fix Yum
Now, the system calls Python 2.7.8 by default, and the execution of Yum will show four errors.
Figure Four: Yum cannot execute
Workaround: Put the first line of code at the beginning of the/usr/bin/yum file:
#!/usr/bin/python
Modified to:
#!/usr/bin/python2.6
6. Install Setuptools and PIP
Playing python can't be without Setuptools and PIP. The installation scripts provided by PIP are used here to automatically install Setuptools and PIP.
wget https://bootstrap.pypa.io/get-pip.pypython get-pip.py
Because the Python installation directory was previously changed, the Python extension executable file is installed in the/usr/local/python/bin directory. To be able to run these files directly, we either create a symbolic link to the/usr/bin directory or add the/usr/local/python/bin directory to the PATH environment variable. To avoid unnecessary conflicts, the way to create symbolic links is used here.
ln -sf /usr/local/python/bin/pip /usr/bin/pipln -sf /usr/local/python/bin/easy_install /usr/bin/easy_install
7, Installation Ipython
With Pip, the installation of Ipython is simply so easy. (also link the Ipython executable file to the/usr/bin directory)
-s /usr/local/python/bin/ipython /usr/bin/ipython
As shown in five.
Figure V: Installation Ipython
8. Installing the ReadLine expansion module
A Ipython without readline support is too weak to be used. Install ReadLine here:
yum install readline-develyum install patch #相信我,不安装这个就无法编译readlinepip install readline
After that, Ipython's highlighting and code completion functions can be used, as shown in six. Of course, now the Ipython only have the most basic functions, and some modules are not installed, so can not use such as parallel computing, Qt Console, notebook and other functions. But that's not what we're going to discuss in this article. There will be time to write an article that installs other modules and features using Ipython.
Figure VI: Installed Ipython
CentOS 6.5 Upgrade python and install Ipython