CentOS6.8安装python2.7.12以及ipython教程

前端之家收集整理的这篇文章主要介绍了CentOS6.8安装python2.7.12以及ipython教程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

注:此操作本人用CentOS6.8最小化安装通过
为了ipython可以保存历史纪录,还需要安装sqlite-devel

1.准备工作

yum-yinstallgccwgetxzunzipzlib-developensslopenssl-develsqlite-devel


2.下载源码

wget
https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz

3.解压:

xz-dPython-2.7.12.tar.xz
tarxfPython-2.7.12.tar
cdPython-2.7.12
./configure--prefix=/usr/local/python
make
makeinstall

3.替换系统自带Python
安装后,Python 2.7.8的可执行文件位于/usr/local/python/bin。先将系统自带的Python重命名为python2.6.6,再创建新的Python到/usr/bin目录下的符号链接

mv/usr/bin/python/usr/bin/python2.6.6
ln-sv/usr/local/python/bin/python2.7/usr/bin/python

4.修正yum
现在,系统默认调用Python 2.7.12,执行yum会出现错误
解决方法:将/usr/bin/yum文件开头的第一行代码

#!/usr/bin/python


改为:

#!/usr/bin/python2.6.6

到此python2.7.12安装完成
接下来安装ipython

ipython安装
1.下载ipython

wget
https://github.com/ipython/ipython/archive/master.zip

2.解压安装

unzipmaster.zip
cdipython-master
pythonsetup.pybuild
pythonsetup.pyinstall

3.创建符号链接

ln-sv/usr/local/python/bin/ipython2/usr/bin/ipython

4.安装pip
此时如果直接运行ipython的话,会提示下面的错误,这是由于没有安装相应的模块导致的:
No module named traitlets.config.application

wget
https://pypi.python.org/packages/9f/7c/0a33c528164f1b7ff8cf0684cf88c2e733c8ae0119ceca4a3955c7fc059d/setuptools-23.1.0.tar.gz

tarxfsetuptools-23.1.0.tar.gz
cdsetuptools-23.1.0
pythonsetup.pyinstall
wget
https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/pip-8.1.2.tar.gz

tarxfpip-8.1.2.tar.gz
cdpip-8.1.2
pythonsetup.pyinstall

创建符号链接

ln-sv/usr/local/python/bin/pip2.7/usr/bin/pip

后执行ipython看提示缺少什么模块就直接

pipinstallmodule_name
pipinstalltraitlets
pipinstallpygments
pipinstallpexpect
pipinstallbackports.shutil_get_terminal_size
pipinstallpathlib2
pipinstallpickleshare
pipinstallprompt_toolkit
pipinstallsimplegeneric

好了 ipython环境搭建好了。

原文链接:https://www.f2er.com/centos/381242.html

猜你在找的CentOS相关文章