在官网可以获得Python的安装介质:
https://www.python.org/downloads/release/python-2713/
https://www.python.org/downloads/release/python-360/
如果你下载的是【tgz】的软件包,你需要按照下面的步骤执行安装:
1. 安装需要的软件包:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc
2. 解压:tar xf xxx.tgz
3. 进入解压后的目录,开始编译:
./configure –prefix=/usr/local/ –enable-shared
make
4. 安装:
make install
5. 配置ldconfig
[root@center-linux Python-2.7.13]# cat /etc/ld.so.conf include ld.so.conf.d/*.conf [root@center-linux Python-2.7.13]# [root@center-linux Python-2.7.13]# echo /usr/local/lib >> /etc/ld.so.conf.d/local_python.conf [root@center-linux Python-2.7.13]# [root@center-linux Python-2.7.13]# cat /etc/ld.so.conf.d/local_python.conf /usr/local/lib [root@center-linux Python-2.7.13]#
6. 应用ldconfig
[root@center-linux Python-2.7.13]# ldconfig [root@center-linux Python-2.7.13]#
注意,如果没有上面ldconfig的配置,那么你在调用python的时候,会遇到错误:
[root@center-linux Python-2.7.13]# python2.7 -V python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory [root@center-linux Python-2.7.13]#
7. 上述步骤完成后,就可以使用python了:
[root@center-linux Python-2.7.13]# python2.7 -V Python 2.7.13 [root@center-linux Python-2.7.13]#
————————————————
Done。