CentOS6.5上安装Python2.7和PIP
目前大部分用户使用的CentOS6.5上默认的Python还是2.6版本。升级到Python2.7碰到很多问题。本文将介绍如何安装Python2.7。
1. 安装必要的准备包
安装过程将用到gcc,方便起见,安装“Development Tools”
yum groupinstall "Development tools"
另外,Python安装中需要的一些依赖包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
2. 下载安装Python2.7
目前Python2.7的最新版本是2.7.11。可以在下面的网站查询:
https://www.python.org/ftp/python/
2.7.11的下载链接是:
https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar vxf Python-2.7.11.tgz
cd Python-2.7.11.tgz
./configure --prefix=/usr/local
make && make install
安装完成后,通过运行python,可以看到版本
>>> import sys
>>> sys.version
'2.7.11 (default, May 6 2016, 01:38:00) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]'
3.安装pip
pip是python的安装工具,很多python的常用工具,都可以通过pip进行安装。
要安装pip,首先要安装setuptools。下面的链接可以得到相关信息,最新版本是21.0.0:
https://pypi.python.org/pypi/setuptools
下载链接:
https://pypi.python.org/packages/ff/d4/209f4939c49e31f5524fa0027bf1c8ec3107abaf7c61fdaad704a648c281/setuptools-21.0.0.tar.gz#md5=81964fdb89534118707742e6d1a1ddb4
同样的,进行安装:
tar vxf setuptools-21.0..tar.gz
cd setuptools-21.0.
python setup.py install
安装完成后,下载pip。其信息在如下网站:
https://pypi.python.org/pypi/pip
最新版是8.1.1,下载链接:
https://pypi.python.org/packages/41/27/9a8d24e1b55bd8c85e4d022da2922cb206f183e2d18fee4e320c9547e751/pip-8.1.1.tar.gz#md5=6b86f11841e89c8241d689956ba99ed7
同样的,进行安装
tar vxf pip-8.1..tar.gz
cd pip-8.1.
python setup.py install
安装完成后,运行pip
[root@hwthstest08 pip-8.1.]# pip Usage:
pip <command> [options] Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion
help Show help for commands. General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to times.
-V, --version Show version and exit.
-q, --quiet Give less output.
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default times).
--timeout <sec> Set the socket timeout (default seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
--trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
[root@hwthstest08 pip-8.1.]#
安装一个程序检测:
[root@hwthstest08 pip-8.1.]# pip install psutil
Collecting psutil
Downloading psutil-4.1..tar.gz (301kB)
% |████████████████████████████████| 307kB 274kB/s
Installing collected packages: psutil
Running setup.py install for psutil ... done
Successfully installed psutil-4.1.
4. 载入常用的tab.py程序
#!/usr/bin/evn python
import sys
import readline
import rlcompleter
import atexit
import os
readline.parse_and_bind('tab: complete')
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
CentOS6.5上安装Python2.7和PIP的更多相关文章
- CentOS 6.5上安装python2.7、pip以及Python命令行补全和yum冲突解决
目前CentOS6.5上自带的python版本为2.6,升级到python2.7会碰到很多问题.本文将介绍如何安装python2.7.pip以及python命令行补全. 一.如何安装python2.7 ...
- [转载] centos6.x x64 安装python2.7
本文转载自: http://www.centoscn.com/image-text/install/2016/0323/6906.html CentOS的设计理念中有一点是:持久可用.要达到这个目的, ...
- CentOS5.5上安装Python2.7及ez_setup和pip包
CentOS5.5上安装Python2.7及ez_setup和pip包 下载 首先从Python官方下载源代码包下载 编译安装 这里将python安装到/opt/python27文件夹下 tar xv ...
- CentOS6下编译安装Python2.7.6方法
关于在CentOS6下编译安装Python2.7.6的方法非常的多了,小编以前也介绍过相关的文章了,下面一聚教程小编再来为各位介绍一下吧,希望文章能帮助到各位. CentOS下面Python在升级 ...
- 最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi
最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi 使用Jexus5.8.1独立版 http://www.linuxdot.net/ ps:该“独立版”支持64位的CentOS ...
- 在CentOS6的上安装Windows2012R2的KVM虚拟机
在CentOS6的上安装Windows2012R2的KVM虚拟机 1:上传cn_windows_server_2012_r2_vl_with_update_x64_dvd_6052729.iso下载驱 ...
- CentOS6.7上安装Mysql5.7
CentOS6.7上安装Mysql5.7 2017年07月22日 18:27:05 阅读数:564 环境的配置总是令人作呕,所以这次表明版本条件: 首先,这是一台新机器 其次,CentOS版本如下: ...
- CentOS6.7上安装nginx1.8.0
主题: CentOS6.7上安装nginx1.8.0 环境准备: 1.gcc-c++ 示例:yum install gcc-c++ 安装:gcc-c++ gcc-c++编译工具 2.PCRE(Perl ...
- centos6.5上安装5.7版本的mysql
centos6.5上安装5.7版本的mysql https://www.cnblogs.com/lzj0218/p/5724446.html 设置root可以在本机以外的机器访问 mysql -uro ...
随机推荐
- 原生javasxript获取浏览器的滚动距离和可视窗口的高度
原生javasxript获取浏览器的滚动距离和可视窗口的高度 //封装兼容性方法获取滚动的距离 function getScrollOffset(){ if(window.pageXOffset){ ...
- NorFlash、NandFlash、eMMC比较区别【转】
本文转载自:http://www.veryarm.com/1200.html 快闪存储器(英语:Flash Memory),是一种电子式可清除程序化只读存储器的形式,允许在操作中被多次擦或写的存储器. ...
- Docker 数据管理-tmpfs mounts
Use tmpfs mounts Volumes and bind mounts are mounted into the container’s filesystem by default, and ...
- 【P2564】生日礼物(单调队列)
这个题看上去状态比较多,实际上由于题目的输出需要,又因为是一个线性的结构,所以我们可以有一些操作. 这么想,如果我们有了一个满足条件的区间,此时我们缩减左端点,然后判断此时是否还是满足,满足就继续缩减 ...
- PAT1023. Have Fun with Numbers (20)
#include <iostream> #include <map> #include <algorithm> using namespace std; strin ...
- Linux嵌入式 -- 内核 - 内存管理
1. 逻辑地址 线性地址 物理地址 段式管理: 16位CPU,20根地址总线,可寻址1M内存,但是只有16位的寄存器,64K. 逻辑地址 = 段基地址 + 段内偏移地址 物理地址 PA = 段 ...
- 关于谷歌浏览器(chrome)的一些好用的插件推荐
很多在测试时候都可以使用 第一部分: A:Adblock Plus for Google Chrome™https://chrome.google.com/webstore/detail/cfhdoj ...
- 如何破解mssql for linux 3.5G内存的限制
在上有篇博客中主要介绍了如何在CentOS 中安装和配置mssql ,在安装过程中遇到3.5G内存的限制,下面介绍如何去破解, 微软发布了SQLServer for Linux,但是安装竟然需要3.5 ...
- MVC 成功创建了数据库,但是数据库对象创建失败[此引用关系将导致不允许的周期性引用]
model 类的属性写错了 错误写法: public province { public int provinceId; public string Name; } public City ...
- 《Advanced Bash-scripting Guide》学习(四):一个显示时间日期登录用户的脚本
本文所选的例子来自于<Advanced Bash-scripting Gudie>一书,译者杨春敏 黄毅 编写一个脚本,显示时间和日期,列出所有的登录用户,显示系统的更新时间.然后这个脚本 ...