Python--linux Installation

Source: Internet
Author: User

Centos7

View default Python version comes with 2.7.5 version

cat /etc/redhat-7.3. 1611 (Core) [[email protected]-node1 ~]# python-2.7. 5
Upgrade version -3.x1, install GCC, for compiling python source code
Yum Install GCC
2 、下载源码包

 官网下载:https://www.python.org/ftp/python/

3 、解压并进入源码文件
[[Email protected] ~]# lltotal14468-RW-------.1Root root1208Dec the   .anaconda-ks.cfg-rw-r--r--1Root root14808460Apr -  the: -python-3.5.0.Tar. Xz[[email protected]-node1 ~]#TarXF python-3.5.0.Tar. Xz[[email protected]-node1 ~]# CD python-3.5.0/[[Email protected]-node1 python-3.5.0]# lltotal980-rw-r--r--1  +  +   8466Sep -   -ACLOCAL.M4-rwxr-xr-x1  +  +  42856Sep -   -config.guess-rwxr-xr-x1  +  +  35740Sep -   -config.sub-rwxr-xr-x1  +  + 464952Sep -   -Configure-rw-r--r--1  +  + 150676Sep -   -CONFIGURE.ACDRWXRWXR-X -  +  +   4096Sep -   -DOCDRWXRWXR-X2  +  +      -Sep -   -GRAMMARDRWXRWXR-X2  +  +   4096Sep -   -Include-rwxr-xr-x1  +  +   7122Sep -   - Install-SHDRWXRWXR-X $  +  +   8192Sep -   -Lib-rw-r--r--1  +  +  12761Sep -   -LICENSEDRWXRWXR-X8  +  +    151Sep -   -Mac-rw-r--r--1  +  +  56690Sep -   -Makefile.pre.inchDRWXRWXR-X2  +  +   4096Sep -   -MISCDRWXRWXR-X One  +  +   4096Sep -   -MODULESDRWXRWXR-X4  +  +   4096Sep -   -OBJECTSDRWXRWXR-X2  +  +   4096Sep -   -PARSERDRWXRWXR-X6  +  +   4096Sep -   -PCDRWXRWXR-X2  +  +   4096Sep -   -PCBUILDDRWXRWXR-X2  +  +      -Sep -   -Programs-rw-r--r--1  +  +  41790Sep -   -Pyconfig.h.inchDRWXRWXR-X3  +  +   4096Sep -   -Python-rw-r--r--1  +  +   6740Sep -   -README-rw-r--r--1  +  +  98075Sep -   -SETUP.PYDRWXRWXR-X A  +  +   4096Sep -   -Tools
4 、编译安装
[Email protected] python-3.5. 0] #./Configure[[email protected]-node1 python-3.5. 0  Make All[[email protected]-node1 python-3.5. 0  Make Install

Note: compilation needs to wait a while ~

5 、查看版本
[Email protected] python-3.5. 0] #/usr/local/bin/python3. 5 -3.5. 0
6 、修改默认Python版本
[Email protected] python-3.5. 0 MV /usr/bin/python/usr/bin/python2. 7.5         #移走旧版本的python并命名为2.7.5[[email protected]-node1 python-3.5.  0Ln -s/usr/local/bin/python3. 5 /usr/bin/python  #做软连接 [[email protected]-node1 python-3.5.  0]# python-V                                       3.5.  0

7 、防止yum执行异常,修改yum使用的Python版本
[Email protected] python-3.5. 0] # vim/usr/bin/Yum    # 将头部  #!/usr/bin/python 修改为 #!/usr/bin/python3.5 [[email protected]-node1 python-3.5.  0cat /usr/bin/yum#!/usr/bin/python3. 5 Import SYS

Python--linux Installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.