Linux下安装python

安装gcc编译器:

yum -y install gcc

 

安装wget:

yum -y install wget

 

安装zlib

yum install zlib

yum install zlib-devel

 


安装python-setuptools:

wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py

 

安装https

yum install mysql-devel

 

安装下载python:

wget http://python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar zxvf Python-2.7.9.tgz
cd Python-2.7.9
./configure --prefix=/usr/local/python2.7
make
make install

 

配置环境默认使用python 2.7:

mv /usr/bin/python /usr/bin/python_old
ln -s /usr/local/python2.7/bin/python /usr/bin

 

 

安装mysql-python:

wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz

cd MySQL-python-1.2.3

python setup.py build

python setup.py install

 

yum需要使用旧版本的python2.4

# vim /usr/bin/yum 

#!/usr/bin/python 修改为 #!/usr/bin/python_old

 

测试mysql-python安装是否安装成功

python

>>> import MySQLdb

你可能感兴趣的:(python)