标签:and cut silent display sage stat atom ack setup
1、查看当前环境中是否存在python安装包
[zyj@localhost ~]$ rpm -qa | grep python gnome-python2-gnome-2.28.0-3.el6.x86_64 python-slip-0.2.20-1.el6_2.noarch python-iniparse-0.3.1-2.1.el6.noarch python-pycurl-7.19.0-9.el6.x86_64 gnome-python2-gconf-2.28.0-3.el6.x86_64 gnome-python2-extras-2.25.3-20.el6.x86_64 gnome-python2-libegg-2.25.3-20.el6.x86_64 notify-python-0.1.1-10.el6.x86_64 python-libs-2.6.6-66.el6_8.x86_64 python-ethtool-0.6-6.el6.x86_64 python-mako-0.3.4-1.el6.noarch abrt-python-2.0.8-43.el6.centos.x86_64 gnome-python2-gnomekeyring-2.28.0-5.el6.x86_64 gnome-python2-bonobo-2.28.0-3.el6.x86_64 python-meh-0.12.1-3.el6.noarch python-2.6.6-66.el6_8.x86_64 libuser-python-0.56.13-8.el6_7.x86_64
2、在官网上查看最新的版本;也可以通过yum install 安装python安装包,但是有可能yum源上面没有最新的python版本,所以采用下载的方式安装最新的安装包。
https://www.python.org/downloads/source/
[root@localhost home]# yum info python //查看yum源上的py安装包信息 Failed to set locale, defaulting to C Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Installed Packages Name : python Arch : x86_64 Version : 2.6.6 Release : 66.el6_8 Size : 78 k Repo : installed From repo : anaconda-CentOS-201703281317.x86_64 Summary : An interpreted, interactive, object-oriented programming language URL : http://www.python.org/ License : Python Description : Python is an interpreted, interactive, object-oriented programming : language often compared to Tcl, Perl, Scheme or Java. Python includes : modules, classes, exceptions, very high level dynamic data types and : dynamic typing. Python supports interfaces to many system calls and : libraries, as well as to various windowing systems (X11, Motif, Tk, : Mac and MFC). : : Programmers can write new built-in modules for Python in C or C++. : Python can be used as an extension language for applications that need : a programmable interface. : : Note that documentation for Python is provided in the python-docs : package. : : This package provides the "python" executable; most of the actual : implementation is within the "python-libs" package. [root@localhost home]# [root@localhost home]# yum search python3 //查询yum源是否有? Failed to set locale, defaulting to C Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Warning: No matches found for: python3 No Matches found
3、安装python源码:
[root@localhost home]# cd zyj [root@localhost zyj]# ll total 31312 drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Desktop drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Documents drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Downloads drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Music drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Pictures drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Public -rw-rw-r--. 1 zyj zyj 22994617 May 1 2018 Python-3.6.5.tgz drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Templates drwxr-xr-x. 2 zyj zyj 4096 Apr 14 09:13 Videos -rw-rw-r--. 1 zyj zyj 9034460 Apr 27 21:23 mysql-server-5.1.73-8.el6_8.x86_64.rpm [root@localhost zyj]# mv Python-3.6.5.tgz ../ [root@localhost home]# ll total 22472 -rwxrwxrwx. 1 root root 10 Apr 25 11:05 1.txt -rw-rw-r--. 1 zyj zyj 22994617 May 1 2018 Python-3.6.5.tgz -rwxrwxrwx. 1 zyj zyj 86 Apr 15 09:23 hello.txt drwxr-xrwx. 2 root root 4096 Apr 15 07:00 x drwx------. 24 zyj zyj 4096 May 1 00:00 zyj
[root@localhost home]# rpm -qa | grep gcc libgcc-4.4.7-18.el6.x86_64 gcc-4.4.7-18.el6.x86_64
[root@localhost home]# yum install gcc-c++ //安装c++编译环境
[root@localhost home]# tar -zxvf Python-3.6.5.tgz //解压安装包 [root@localhost home]# ls 1.txt Python-3.6.5 Python-3.6.5.tgz hello.txt x zyj [root@localhost home]# cd Python-3.6.5 //进入安装包目录下 [root@localhost Python-3.6.5]# ll total 1036 drwxr-xr-x. 18 sl sl 4096 Mar 28 03:24 Doc drwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Grammar drwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Include -rw-r--r--. 1 sl sl 12763 Mar 28 02:19 LICENSE drwxr-xr-x. 33 sl sl 4096 Mar 28 02:19 Lib drwxr-xr-x. 8 sl sl 4096 Mar 28 02:19 Mac -rw-r--r--. 1 sl sl 61032 Mar 28 02:19 Makefile.pre.in drwxr-xr-x. 2 sl sl 4096 Mar 28 03:24 Misc drwxr-xr-x. 13 sl sl 4096 Mar 28 02:19 Modules drwxr-xr-x. 4 sl sl 4096 Mar 28 02:19 Objects drwxr-xr-x. 6 sl sl 4096 Mar 28 02:19 PC drwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 PCbuild drwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Parser drwxr-xr-x. 2 sl sl 4096 Mar 28 02:19 Programs drwxr-xr-x. 3 sl sl 4096 Mar 28 02:19 Python -rw-r--r--. 1 sl sl 9281 Mar 28 02:19 README.rst drwxr-xr-x. 23 sl sl 4096 Mar 28 02:19 Tools -rw-r--r--. 1 sl sl 13335 Mar 28 02:19 aclocal.m4 -rwxr-xr-x. 1 sl sl 44259 Mar 28 02:19 config.guess -rwxr-xr-x. 1 sl sl 36515 Mar 28 02:19 config.sub -rwxr-xr-x. 1 sl sl 490243 Mar 28 02:19 configure -rw-r--r--. 1 sl sl 163178 Mar 28 02:19 configure.ac -rwxr-xr-x. 1 sl sl 7122 Mar 28 02:19 install-sh -rw-r--r--. 1 sl sl 42152 Mar 28 02:19 pyconfig.h.in -rw-r--r--. 1 sl sl 104570 Mar 28 02:19 setup.py
执行可执行文件:
[root@localhost Python-3.6.5]# ./configure --help `configure‘ configures python 3.6 to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print `checking ...‘ messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for `--cache-file=config.cache‘ -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or `..‘] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] ...... Report bugs to <https://bugs.python.org/>. [root@localhost Python-3.6.5]# ./configure --prefix=/usr/python-3.6.5 //第三方软件安装在/usr/ 目录下。 checking whether gcc -pthread supports computed gotos... yes checking for build directories... done checking for -O2... yes checking for glibc _FORTIFY_SOURCE/memmove bug... no checking for gcc ipa-pure-const bug... no checking for stdatomic.h... no checking for GCC >= 4.7 __atomic builtins... no checking for ensurepip... upgrade checking if the dirent structure of a d_type field... yes checking for the Linux getrandom() syscall... no checking for the getrandom() function... no configure: creating ./config.status config.status: creating Makefile.pre config.status: creating Modules/Setup.config config.status: creating Misc/python.pc config.status: creating Misc/python-config.sh config.status: creating Modules/ld_so_aix config.status: creating pyconfig.h creating Modules/Setup creating Modules/Setup.local creating Makefile If you want a release build with all stable optimizations active (PGO, etc), please run ./configure --enable-optimizations
准备安装依赖包:zlib、openssl。python的pip需要依赖这两个包。
[root@localhost home]# yum install zlib* openssl* //安装依赖包 [root@localhost home]# cd Python-3.6.5 [root@localhost Python-3.6.5]# ls Doc LICENSE Makefile Misc PC Programs Tools config.log configure pyconfig.h Grammar Lib Makefile.pre Modules PCbuild Python aclocal.m4 config.status configure.ac pyconfig.h.in Include Mac Makefile.pre.in Objects Parser README.rst config.guess config.sub install-sh setup.py [root@localhost Python-3.6.5]# ./configure --prefix=/usr/python-3.6.5 --enable-optimizations //完整的预编译 ... creating Modules/Setup creating Modules/Setup.local creating Makefile //没有任何报错 [root@localhost Python-3.6.5]#
[root@localhost Python-3.6.5]# make ... make[1]: Entering directory `/home/Python-3.6.5‘ find . -name ‘*.gc??‘ -exec rm -f {} ‘;‘ find . -name ‘*.profclang?‘ -exec rm -f {} ‘;‘ find . -name ‘*.dyn‘ -exec rm -f {} ‘;‘ rm -f /home/Python-3.6.5/coverage.info rm -rf /home/Python-3.6.5/lcov-report make[1]: Leaving directory `/home/Python-3.6.5‘ [root@localhost Python-3.6.5]# //一般检查最后几行有没有error
[root@localhost Python-3.6.5]#make install ...... Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-9.0.3 setuptools-39.0.1 [root@localhost Python-3.6.5]#
标签:and cut silent display sage stat atom ack setup
原文地址:https://www.cnblogs.com/zhaoyujiao/p/8975669.html