Unix/Linux系统下基本上都预安装了Python,但有时候它的版本可能不是符合我们要求的。CentOS6.0默认安装版本是2.6,而现在Python最新的版本是3.2.2. 为此下面记录了在CentOS上安装Python3.2.2的详细过程:
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
# Fetch and extract source. Please refer to http://www.python.org/download/releases
# to ensure the latest source is used.
wget http://www.python.org/ftp/python/3.2.2/Python-3.2.2.tar.bz2
tar -xjf Python-3.2.2.tar.bz2
cd Python-3.2.2
./configure --prefix=/opt/python3
checking for gcc… no
checking for cc… no
checking for cl.exe… no
configure: error: in `/opt/Python-2.7.2′:
configure: error: no acceptable C compiler found in $PATH
See `config.log’ for more details
yum -y install gcc
然后再执行:
# Configure the build with a prefix (install dir) of /opt/python3, compile, and install.
./configure --prefix=/opt/python3
make
sudo make install
4)检查Python3安装目录
---------------------------------------------------------------------
$/opt/python3/bin/python3 -V
Python 3.2.2