Upgrade python2.7.X to Python3.6.X, and upgrade macpython2.7 to 3.6.

Source: Internet
Author: User
Tags install openssl

Upgrade python2.7.X to Python3.6.X, and upgrade macpython2.7 to 3.6.

Upgrade python2.7.X to Python36.X


Install Python3


The project is encoded in the py3 environment, and the default Centos py version is 2. We also need to install py3 to run the program. Before that, we need to install the development kit, because you need to compile and install Python
[Root @ CentOS ~] # Yum-y group install "Development Tools"


Install the Python dependency package. If you do not install the dependency, you may not have pip3 software after installation.
[Root @ CentOS ~] # Yum-y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel vim


Download the latest Python3.5.x
[Root @ CentOS ~] # Wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
You may need to install wget through yum-y


Decompress, compile, and install
[Root @ CentOS ~] # Tar xf Python-3.5.3.tgz
[Root @ CentOS ~] # Cd Python-3.5.3
[Root @ CentOS Python-3.5.3] #./configure -- prefix =/usr/local/python3.5
[Root @ CentOS Python-3.5.3] # make
[Root @ CentOS Python-3.5.3] # make altinstall

 

Create links for pip3 and python3
[Root @ CentOS Python-3.5.3] # ln-fs/usr/local/python3.5/bin/python3/usr/local/bin/
[Root @ CentOS Python-3.5.3] # ln-fs/usr/local/python3.5/bin/pip3/usr/local/bin/
[Root @ CentOS Python-3.5.3] # mv/usr/bin/python/usr/bin/python_old
[Root @ CentOS Python-3.5.3] # ln-fs/usr/local/python3.5/bin/python3.5/usr/bin/python
[Root @ CentOS Python-3.5.3] # ln-fs/usr/local/python3.5/bin/pip3.5/usr/bin/pip


Verify Installation
[Root @ CentOS Python-3.5.3] # Rip-V
Pip 9.0.1 from/usr/local/python3.5/lib/python3.5/site-packages (python 3.5)
[Root @ CentOS Python-3.5.3] # python-V
Python 3.5.3


Modify the yum file. Otherwise, yum cannot be downloaded.
Vim/usr/bin/yum
#! /Usr/bin/python #! /Usr/bin/python2.7 save to take effect

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.