Coexistence of python2.x and python3.x under Centos7

Source: Internet
Author: User
Tags virtual environment

Summary

Currently the CENTOS7 system comes with the Python version is 2.7.5, this version of the system is a lot of program lock dependencies, all we can not go to delete it. If this time we also want to use the python3.x version, in fact there are two ways, one is to use pyenv to create a pure python3.x environment, you can refer to the CentOS pure virtual environment of Python, the other is described here.

Download
[email protected]/0 $ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz--2018-01-11 17:13:58--  https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz正在解析主机 www.python.org (www.python.org)... 151.101.228.223, 2a04:4e42:36::223正在连接 www.python.org (www.python.org)|151.101.228.223|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:22540566 (21M) [application/octet-stream]正在保存至: “Python-3.6.1.tgz”100%[=========================================================================================>] 22,540,566  3.34MB/s 用时 7.8s2018-01-11 17:14:06 (2.74 MB/s) - 已保存 “Python-3.6.1.tgz” [22540566/22540566])
Depend on

Prior to the installation, it is necessary to install a number of dependencies to ensure that subsequent installations are properly

yum install -y gcc gcc-c++ autoconf automake zlib-devel
Installation
# unzip [email protected]/0 $ tar-zxf python-3.6.1.tgz[email protected]/0 $ ll Total dosage 26112drwxr-xr-x 17 501 501 4096 March python-3.6.1-rw-r--r--1 root root 22540566 March python-3.6.1.tgz# compilation is installed by default under/usr/local. Here we customize the installation path by configure the--prefix parameter, convenient for later uninstall [email protected]/0 $ cd python-3.6.1[email protected]/0 $./ Configure--prefix=/usr/local/python3checking Build system type ... x86_64-unknown-linux-gnuchecking host system type ... x86_64-unknown-linux-gnuchecking for python3.6 ... nochecking for python3 ... nochecking for python ... pythonchecking f Or--enable-universalsdk ... nochecking for--with-universal-archs ... nochecking machdep ... linuxchecking for-- WITHOUT-GCC ... nochecking for--WITH-ICC ... nochecking for gcc ... gccchecking whether the C compiler works ... yeschecking For C compiler default output file name ... a.outchecking for suffix of executables...checking whether we is cross Compili ng ... no# installation [EMAIL PROTECTED]/1 $ make && mAke Install 
Verify
[email protected]/1 $ ls -l /usr/local/python3/总用量 16drwxr-xr-x 2 root root 4096 1月  11 17:09 bindrwxr-xr-x 3 root root 4096 1月  11 17:09 includedrwxr-xr-x 4 root root 4096 1月  11 17:09 libdrwxr-xr-x 3 root root 4096 1月  11 17:09 share[email protected]/1 $ /usr/local/python3/bin/python3 -VPython 3.6.1[email protected]/1 $ /usr/local/python3/bin/python3Python 3.6.1 (default, Jan 11 2018, 17:08:20)[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linuxType "help", "copyright", "credits" or "license" for more information.>>>

Coexistence of python2.x and python3.x under Centos7

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.