本文摘自php中文网,作者不言,侵删。
本篇文章主要介绍了详解Python 2.6 升级至 Python 2.7 的实践心得,具有一定的参考价值,感兴趣的小伙伴们可以参考一下前言
CentOS 6.8 安装 Python 2.7.13,因为软件版本上的需求所以考虑将 Python 升级至 2.7.13,加上生产环境还是以 RHEL 6 为主,互联网自动化运维平台大多数也推荐以Python 2.7.x + CentOS 6.x 来操作,选择 Python 2 还是 Python 3 也没有定论,找到适合的搭配即可。
简单安装
因为Python 2.7.13以后版本会自动完善yum配置,所以不必参考以前的网上文章去修改其他地方
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | python --version
Python 2.6.6
cat /etc/redhat-release
CentOS release 6.8 (Final)
yum groupinstall -y "Development tools"
yum install -y zlib-devel bzip2 -devel openssl-devel ncurses-devel sqlite-devel
tar zxf Python-2.7.13.tgz
cd Python-2.7.13
. /configure
make && make install
python --version
Python 2.7.13
|
ansible离线安装实践
这里利用了一些内网离线安装ansible的小技巧。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | tar xf Python-2.7.13.tgz
cd Python-2.7.13
. /configure
make
make install
tar xf six-1.10.0. tar .gz
cd six-1.10.0
python setup.py install
cd ..
tar xf packaging-16.8. tar .gz
cd packaging-16.8
python setup.py install
cd ..
tar xf pyparsing-2.2.0. tar .gz
cd pyparsing-2.2.0
python setup.py install
cd ..
tar xf appdirs-1.4.3. tar .gz
cd appdirs-1.4.3
python setup.py install
cd ..
unzip setuptools-34.2.0.zip
cd setuptools-34.2.0
python setup.py install
cd ..
tar xf pip-9.0.1. tar .gz
cd pip-9.0.1
python setup.py install
cd ..
pip install -d ~ /tmp/ ansible
pip install -d ~ /tmp/ ansible-cmdb
pip install ansible --index-url=http: //172 .31.197.1:7000 /simple/ --trusted-host=172.31.197.1
pip install ansible-cmdb --index-url=http: //172 .31.197.1:7000 /simple/ --trusted-host=172.31.197.1
[root@ansible-wangao ansible]
pip 9.0.1 from /usr/local/lib/python2 .7 /site-packages/pip-9 .0.1-py2.7.egg (python 2.7)
[root@ansible-wangao ansible]
ansible 2.3.0.0
config file = /etc/ansible/ansible .cfg
configured module search path = Default w /o overrides
python version = 2.7.13 (default, Apr 25 2017, 17:19:23) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
[root@ansible-wangao ansible]
ansible-cmdb v1.20
vim $HOME/.pip /pip .conf
[global]
index-url = https: //pypi .doubanio.com /simple/
[ install ]
trusted-host=pypi.doubanio.com
|
Windows 安装 Python 2.7.x
下载Python,如 2.7.13
https://www.python.org/downlo...
https://www.python.org/ftp/py...
安装时注意勾选环境变量Add python.exe to Path
安装python2.7.13默认自带pip版本为9.0.1
PS C:UsersAdministrator> pip -V
pip 9.0.1 from c:python27libsite-packages (python 2.7)
安装Python后升级pippython -m pip install --upgrade pip
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import os
ini =
pippath = os.environ[ "USERPROFILE" ] + "\\pip\\"
if not os.path.exists(pippath):
os.mkdir(pippath)
with open (pippath + "pip.ini" , "w+" ) as f:
f.write(ini)
|
以上就是详解Python 2.6 升级至 Python 2.7 的实践心得的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
信息竞赛一定要Python吗
Python怎么画直线
Python下载要钱吗
pycharm和Python区别
Python实现两个文件合并功能
Python引用传值概念的示例详解
Python如何编写公众号
Python抓取网页乱码的原因及解决方法
如何删除 list 中指定 index 的元素
Python利用smtplib实现qq邮箱发送邮件
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 详解Python 2.6 升级至 Python 2.7 的实践心得