CentOS 6 system default Python version is: 2.6.6 usually encountered in the use of a lot of library requirements are 2.7.x version of the library, such as using the Configparser library, in the 2.6 repository does not support the configuration items without value values, need to upgrade to more than 2.7 of the library line , try upgrading Python to version 2.7.x this time, as recorded here.
The Zabbix is installed in the centos6.5, but the alarm needs to be sent, version 2.7 is required, so upgrade.
First, upgrade Python 2.7. Version 10
1. Prepare the installation package, the system is minimized installation
Yum install vim gcc make wget-y
Yum install openssl-devel zlib-devel readline-devel sqlite-devel-y\
Download
Cd/usr/local/src
wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
Extract
TAR-ZXVF python-2.7.10.tgz
Ls
Python-2.7.10 python-2.7.10.tgz
2. Compiling the configuration installation
CD Python-2.7.10
./configure--enable-shared--enable-loadable-sqlite-extensions \
--prefix=/usr/local/python27--with-zlib--with-ssl
Vim./modules/setup # Find the following line, remove the comment
#zlib zlibmodule.c-i$ (prefix)/include-l$ (exec_prefix)/lib-lz
Make && make install
3. View Python version information
Python-v
Python 2.6.6
# version is still 2.6.6
4. Replace the old version with python2.7
cd/usr/bin/
LS python*-L # old Python version information
-rwxr-xr-x. 2 root root 4864 February python
lrwxrwxrwx. 1 root root 6 October 18:38 python2-Python
-rwxr-xr-x. 2 root root 4864 February python2.6
[Email protected] bin]# mv/usr/bin/python/usr/bin/python2.6.6
[Email protected] bin]# ln-s/usr/local/python27/bin/python2.7/usr/bin/python
[[email protected] bin]# ls python*-l
lrwxrwxrwx. 1 root root 33 October 00:01 python--/usr/local/python27/bin/python2.7
lrwxrwxrwx. 1 root root 6 October 18:38 python2-Python
-rwxr-xr-x. 2 root root 4864 February python2.6
-rwxr-xr-x. 2 root root 4864 February python2.6.6
5. Re-verify Python version information
[Email protected] bin]# python-v
Python 2.7.10
As you can see, the Python version that the system recognizes is already Python 2.7.10
To perform the python-v problems encountered:
Python:error while loading shared libraries:libpython2.7.so.1.0:cannot open Shared object file:no such file or Directo Ry
# Reason: Linux system does not add/usr/local/python27/lib path to dynamic library search path by default
Solve:
[Email protected] ~]# vim/etc/ld.so.conf
# Add the following line of content
/usr/local/python27/lib
[[email protected] ~]# Ldconfig # make the newly added path take effect
Second, to solve the Yum compatibility problem
Because Yum is not compatible with Python 2.7, Yum does not work properly and we need to specify Yum python as 2.6.
1. Problems with Yum after upgrading Python
[email protected] bin]# Yum
There was a problem importing one of the Python modules
Required to run Yum. The error leading to this problem was:
No module named Yum
... ... ... ...
2. Edit the Yum configuration file
[Email protected] bin]# Vim/usr/bin/yum
#!/usr/bin/python
# The first line is modified to python2.6.6
#!/usr/bin/python2.6.6
3. Verifying Yum Problem resolution
[email protected] bin]# Yum repolist
Loaded Plugins:fastestmirror
Loading mirror speeds from cached hostfile
... ... ... ...
Third, after upgrading Python, install the PIP tool
1. Download and install
[Email protected] ~]# wget https://bootstrap.pypa.io/get-pip.py
[email protected] ~]# python get-pip.py
2. Setting up a soft connection
[Email protected] ~]# ln-s/USR/LOCAL/PYTHON27/BIN/PIP2.7/USR/BIN/PIP
Iv. installation of Ipython
[[Email protected] ~]# pip install ipython==1.2.1
[Email protected] ~]# ln-s/usr/local/python27/bin/ipython/usr/bin/ipython
Python upgrade version 2.6 to 2.7