CentOS 7 Installation python3.5.1

Source: Internet
Author: User

System:

[Email protected] ~]# cat/etc/centos-release

CentOS Linux release 7.2.1511 (Core)

Kernel:

[Email protected] ~]# uname-r
3.10.0-327.el7.x86_64

1. See if Python is already installed

CENTOS7 is installed by default python2.7.5 because some commands use it like Yum it uses python2.7.5.

Use the PYTHON-V command to see if Python is installed:

[Email protected] ~]# python-v
Python 2.7.5

To view the location of the Python executable file:

[[email protected] ~]# which Python
/usr/bin/python

Go to the Bin directory:

[Email protected] ~]# cd/usr/bin/

[Email protected] bin]# ll python*
lrwxrwxrwx. 1 root root 7 March 04:05 python--Python2
lrwxrwxrwx. 1 root root 9 March 04:05 Python2-python2.7
-rwxr-xr-x. 1 root root 7136 November python2.7

You can see the executable file Python pointing to Python2,python2 and pointing to python2.7, which means that the Python command executes the system preinstalled Python2.7.

To install another version of Python, first execute the MV Python python.bak command to back up the python file.

[Email protected] bin]# mv Python python.bak

install a new version of Python (3.5.1)

[Email protected] ~]# wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz

[Email protected] ~]# tar-zxvf python-3.5.1.tgz    

[Email protected] ~]# CD Python-3.5.1         

[[email protected] python-3.5.1]# ./configure--prefix=/usr/local/python/python3 #--prefix Specify the installation directory, Do not specify the installation directory can also (single./configure can also)

Execute the./configure--prefix=/usr/local/python/python3 command: After the/configure command is complete, create a file creating Makefile for the following make command to use the Execute made Installation will install the program into the directory we specify.

Configure is an executable script that has many options for using commands under the source path to be installed./configure–help output A detailed list of options.

Where the--prefix option is the path of the configuration installation, if this option is not configured, the executable file is placed by default in/usr/local/bin after installation, and the library file is
In/usr/local/lib, the configuration file is placed by default in/usr/local/etc, and other resource files are placed in/usr/local/share, which is more messy.

If you configure--prefix, such as:
./configure--prefix=/usr/local/test
All resource files can be placed in the/usr/local/test path without clutter.
Another benefit of using the-PREFIX option is uninstalling the software or porting the software. When one of the installed software is no longer needed, simply delete the installation directory,
You can uninstall the software cleanly; the porting software simply copies the entire directory to another machine (the same operating system).

Of course, to uninstall the program, you can also use the original make directory once made uninstall, but only if the make file specified uninstall.

Then execute the make, make install command.

After successful installation, go to the Python3 folder to see the Python executable directory, the Lib directory and other related directories.

[[email protected] python-3.5.1]# make

[[email protected] python-3.5.1]# make install

[Email protected] python-3.5.1]# cd/usr/local/python/python3/
[[email protected] python3]# ls
Bin include Lib Share
[Email protected] python3]#ln-s/usr/local/python/python3/bin/python3/usr/bin/python #创建软连接

[Email protected] python3]# python-v #查看新安装的python是否安装成功
Python 3.5.1

Installation succeeded:

The command to quit Python is:quit ()

To modify a Yum configuration file:

Because Yum uses python2, it may not work properly after replacing with Python3, and continue to use this python2.7.5

Therefore, the Yum configuration file is modified.

Change the #!/usr/bin/python of the file head to #!/usr/bin/python2.7 Save and exit.

Because Yum uses python2, it may not work properly after replacing with Python3, and continuing with this python2.7.5 modifies the Yum configuration file (Vi/usr/bin/yum). Change the #!/usr/bin/python of the file head to #!/usr/bin/python2.7 save exit

CentOS 7 Installation python3.5.1

Related Article

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.