Linux下python开发环境的准备

升级python

 安装依赖:

  yum install lrzsz zlib zlib-devel  openssl  readline-deve gcc  ibffi-devel python-devel openssl-devel  mysql-devel libxml2 libxml2-dev libxslt*  -y

 

1、安装gcc,用于编译Python源码
yum install gcc
2、下载源码包,https://www.python.org/ftp/python/
3、解压并进入源码文件
4、编译安装
./configure
make all
make install
5、查看版本
/usr/local/bin/python2.7 -V
6、修改默认Python版本
mv /usr/bin/python /usr/bin/python2.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
7、防止yum执行异常,修改yum使用的Python版本
vi /usr/bin/yum
将头部 #!/usr/bin/python 修改为 #!/usr/bin/python2.6

 

安装pip

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

 

pip install paramiko

(1)下载setuptools包
# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
(2)解压setuptools包
# tar zxvf setuptools-2.0.tar.gz
# cd setuptools-2.0
(3)编译setuptools
# python setup.py build
(4)开始执行setuptools安装
# python setup.py install

 python自动补全

#!/usr/bin/env python
#-*-coding:utf-8-*-
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

  

posted @ 2016-06-21 09:04  Nuwanda  阅读(609)  评论(0编辑  收藏  举报