CentOS6.6 's own Pythonversion to 2.6. 6,want to upgrade him, installing Python2.7.9
First, Preparing the installation package
wget https://bootstrap.pypa.io/get-pip.py #下载setuptools和pip wget Https://pypi.python.org/packages/source/i/ipython /ipython-3.1.0.tar.gz #下载ipython wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz #下载python
II , install dependency package
Install Readline-devel to support the backspace after installation of Python , Install gcc, otherwise the configuration will be error, resulting in failure to install ; and some extension modules
Yum-y Install readline-develyum-y install gccyum-y install zlib-devel openssl-devel sqlite-devel
Third, installation python2.7.9
since the downloaded python package is in XZ format, extracting the Tar.xz file requires xz-d xxx.tar.xz, and then the tar ZVF command will Xxx.tar unpack
xz -d python-2.7.9.tar.xztar xvf python-2.7.9.tarcd python-2.7.9./configure --prefix=/usr/local/pythonmake && make installmv /usr/bin/python /usr/bin/python2.6.6 #把之前版本的python重命名ln -sv /usr/local/python/bin/ python2.7 /usr/bin/python[[email protected] ~]# pythonpython 2.7.9 (Default, nov 22 2017, 09:37:44) [GCC 4.4.7 20120313 (red hat 4.4.7-18)] on linux2type "Help", "copyright", "credits" or "license" For more information.>>> import ssl>>>
Four, Installing Ipython
You can also install Pip first , and then use PIP install Ipython to install Ipython
tar zxvf ipython-3.1.0.tar.gzcd ipython-3.1.0python setup.py buildpython setup.py installln -sv /usr/local/python/bin/ipython /usr/bin/ipython[[email Protected] ~]# ipython warning: ipython history requires sqlite, your history will not be savedPython 2.7.9 (default, nov 22 2017 , 09:37:44) Type "copyright", "credits" or "license" for more Information. ipython 3.1.0 -- an enhanced interactive python.? -> introduction and overview of ipython ' s features.%quickref -> quick reference.help -> python ' S own help system.object? -> details about ' object ', use ' object?? ' &nBSP;FOR EXTRA DETAILS. IN [1]: IMPORT SYS IN [2]: 3+2OUT[2]:  5 IN [3]:
Five, installing setuptools and Pip
Execute the command directly below the command line.
Python get-pip.py[[email protected] ~]# pip Listipython (3.1.0) numpy (1.13.3) pip (9.0.1) setuptools (37.0.0) Wheel (0.30.0 )
Six, I met a few pits here, very troublesome:
1. when you install pip, you encounter Zipimport. Zipimporterror:can ' t decompress data this error
Workaround:
Vim Python-2.7.9/modules/setup
Find the place below and remove the comment
zlib zlibmodule.c-i$ (prefix)/include-l$ (exec_prefix)/lib-lz
and then use
Make && make install
Recompile python
2, install pip again when you encounter the following error:
pip is configured with locations that require tls/ssl, however the ssl module in python is not Available. Collecting sixcould not fetch url https://pypi.python.org/simple/six/: there was a problem confirming the ssl certificate: can ' T connect to HTTPS URL because the SSL module is not available. - skippingcould not find a version that satisfies the requirement six (from versions: ) no matching distribution found for six
Workaround:
Vim Python-2.7.9/modules/setup
Find the following to remove the comment, save the exit
Ssl=/usr/local/ssl_ssl _ssl.c-duse_ssl-i$ (SSL)/include-i$ (SSL)/include/openssl-l$ (SSL)/lib-lssl-lcry Pto
and then use
Make && make install
Recompile python
3. after installing the new Python version, it was strange to find that the Yum command could not be used
Workaround: Originally the Yum command relies on the Python environment and needs to change the path variables of the python called by Yum.
[email protected] ~]# which yum/usr/bin/yum[[email protected] ~]# Vim/usr/bin/yum
Modify the first line:
#!/usr/bin/python2.6.6
Use the Yum command again, ok!
This article is from the "Qing Miao write" blog, please be sure to keep this source http://qingmiao.blog.51cto.com/7286083/1984071
Centos6.6 upgrade python and install Ipython, pip summary