Python具有丰富和强大的库。能够把用其他语言制作的各种模块(尤其是C/C++)很轻松地联结在一起。常见的一种应用情形是,使用Python快速生成程序的原型(有时甚至是程序的最终界面),然后对其中有特别要求的部分,用更合适的语言改写,比如3D游戏中的图形渲染模块,性能要求特别高,就可以用C/C++重写,而后封装为Python可以调用的扩展类库。需要注意的是在您使用扩展类库时可能需要考虑平台问题,某些可能不提供跨平台的实现。
1、准备工作下载 Python3.5代码包
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz
2、解压下载包并安装,具体如下:
[root@localhost reviewboard]# xz -d Python-3.5.0.tar.xz [root@localhost reviewboard]# tar -zxvf Python-3.5.0.tar [root@localhost reviewboard]# cd Python-3.5.0 [root@localhost Python-3.5.0]# ./configure --prefix=/usr/local/python3 [root@localhost Python-3.5.0]# make && make install
做软链,执行命令:
[root@localhost Python-3.5.0]# ln -s /usr/local/python3/bin/python3.5 /usr/local/bin/python3
3、如果提示:Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS,具体信息如下:
(cd /usr/local/python3/share/man/man1; ln -s python3.5.1 python3.1) if test "xupgrade" != "xno" ; then \ case upgrade in \ upgrade) ensurepip="--upgrade" ;; \ install|*) ensurepip="" ;; \ esac; \ ./python -E -m ensurepip \ $ensurepip --root=/ ; \ fi Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS
原因是没有安装或升级oenssl,执行命令如下:
[root@localhost Python-3.5.0]# yum install openssl-devel
4、再次重复编译 python3.5.0,执行make clean 和 ./configure --prefix=/usr/local/python3 以及 make && make install命令。
执行后结果如下:
if test "xupgrade" != "xno" ; then \ case upgrade in \ upgrade) ensurepip="--upgrade" ;; \ install|*) ensurepip="" ;; \ esac; \ ./python -E -m ensurepip \ $ensurepip --root=/ ; \ fi Ignoring indexes: https://pypi.python.org/simple Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-7.1.2 setuptools-18.2
5、提示信息时同时成功安装pip-7.12与setuptools-18.2,pip3与pip提示没有错误,做软链执行命令如下:
[root@localhost Python-3.5.0]# ln -s /usr/local/python3/bin/pip3.5 /usr/local/bin/pip
升级pip到最新版本,执行命令:
[root@localhost Python-3.5.0]# pip install --upgrade pip