歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS6.5安裝Python2.7.8以及安裝iPython

CentOS6.5安裝Python2.7.8以及安裝iPython

日期:2017/2/28 14:24:31   编辑:Linux教程

CentOS6.5安裝python2.7.8以及安裝iPython,Ipython支持tab補全 當然默認的python也可以支持。

安裝python2.7.8

[root@kcw ipython-2.3.0]# tar xf ipython-2.3.0.tar.gz
[root@kcw ipython-2.3.0]# cd ipython-2.3.0
[root@kcw ipython-2.3.0]# /usr/local/python27/bin/python2.7 setup.py build
[root@kcw ipython-2.3.0]# /usr/local/python27/bin/python2.7 setup.py install
測試iPython是否可用
[root@kcw ipython-2.3.0]# /usr/local/python27/bin/ipython
WARNING: IPython History requires SQLite, your history will not be saved
Python 2.7.8 (default, Oct 26 2014, 20:29:45)
Type "copyright", "credits" or "license" for more information.

IPython 2.3.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??' for extra details.

In [1]: print "Hello py"
Hello py

In [2]: import sys

In [3]: sys.<tab><tab>

為了方便使用可用使用一個軟鏈接

[root@kcw ipython-2.3.0]# ln -sv /usr/local/python27/bin/python2.7 /usr/bin/python27
`/usr/bin/python27' -> `/usr/local/python27/bin/python2.7'
[root@kcw ipython-2.3.0]# ln -sv /usr/local/python27/bin/ipython /usr/bin/
`/usr/bin/ipython' -> `/usr/local/python27/bin/ipython'

這樣在bash裡面直接使用就可以了,注意你的系統裡就有2個版本的python和一個iPython了,直接使用就行。

[root@kcw ipython-2.3.0]# python27
Python 2.7.8 (default, Oct 26 2014, 20:29:45)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@kcw ipython-2.3.0]# ipython
WARNING: IPython History requires SQLite, your history will not be saved
Python 2.7.8 (default, Oct 26 2014, 20:29:45)
Type "copyright", "credits" or "license" for more information.

IPython 2.3.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??' for extra details.

In [1]:


最後直接寫了個腳本

#!/bin/bash
#
#rpm -q python
#升級python為2.7 注意不要卸載系統自帶的python,因為系統自帶的好多軟件依賴自帶的python
dir=/tmp/iPython
file=Python-2.7.8.tar.xz
file2=ipython-2.3.1.tar.gz
num=`rpm -q python|grep python-2.7` #判斷你當前系統上的python 如果是2.7 請單獨安裝ipython即可
if [ $? -eq 0 ]
then
echo "你的python版本是2.7及以上,請單獨安裝iPython Usage:yum install ipython 或者看下面安裝ipython的方法即可"
exit 0
fi
############################################################################################
if [ -d $dir ]
then
echo "iPython exist"
else
sudo mkdir iPython
fi
############################################################################################
cd iPython
if [ -f $file ]
then
echo "$file is exist"
tar xf Python-2.7.8.tar.xz
cd Python-2.7.8
./configure --prefix=/usr/local/python27
sudo make && make install
else
wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
tar xf Python-2.7.8.tar.xz
cd Python-2.7.8
sudo ./configure --prefix=/usr/local/python27
sudo make && make install
fi
##############################################################################################
#iPython 安裝 依賴python2.7
if [ -f $file2 ]
then
echo "$file1 is exist"
tar xf ipython-2.3.1.tar.gz
cd ipython-2.3.1
sudo /usr/local/python27/bin/python2.7 setup.py build
sudo /usr/local/python27/bin/python2.7 setup.py install

else
wget https://pypi.python.org/packages/source/i/ipython/ipython-2.3.1.tar.gz#md5=2b7085525dac11190bfb45bb8ec8dcbf
tar xf ipython-2.3.1.tar.gz
cd ipython-2.3.1
sudo /usr/local/python27/bin/python2.7 setup.py build
sudo /usr/local/python27/bin/python2.7 setup.py install
fi
#安裝完成後為了添加軟鏈接以便直接使用,注意這時候你有2個python一個是python27這是新版本的python和你系統自帶的python
sudo ln -sv /usr/local/python27/bin/python2.7 /usr/bin/python27
sudo ln -sv /usr/local/python27/bin/ipython /usr/bin/

Python向PHP發起GET與POST請求 http://www.linuxidc.com/Linux/2014-10/107903.htm

《Python核心編程 第二版》.(Wesley J. Chun ).[高清PDF中文版] http://www.linuxidc.com/Linux/2013-06/85425.htm

《Python開發技術詳解》.( 周偉,宗傑).[高清PDF掃描版+隨書視頻+代碼] http://www.linuxidc.com/Linux/2013-11/92693.htm

Python腳本獲取Linux系統信息 http://www.linuxidc.com/Linux/2013-08/88531.htm

在Ubuntu下用Python搭建桌面算法交易研究環境 http://www.linuxidc.com/Linux/2013-11/92534.htm

Python 語言的發展簡史 http://www.linuxidc.com/Linux/2014-09/107206.htm

Python 的詳細介紹:請點這裡
Python 的下載地址:請點這裡

Copyright © Linux教程網 All Rights Reserved