[linux]centos7.4 upgrade Python2 version to python3.6.5 "Install dual version, default Python3"

Source: Internet
Author: User

Version Declaration

centos7.4

The Python on Linux is version 2 by default, and the Django Project is a 3 version, so we have to upgrade to the next version.

1. Download python3.6.5

cd/usr/local/

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

TAR-XVF python-3.6.5.tgz extracted directory renamed MV Python-3.6.5 python36

2. Install, directory settings yourself decompression

./configure--prefix=/usr/local/python36

Make

Make install

Or

Direct make && make install

If the error zipimport. Zipimporterror:can ' t decompress data uses yum-y install zlib* installation related dependencies, then make && make install

mv/usr/bin/python/usr/bin/python2.6.6 the previous version to expire

Add a new version of Python's soft connection to the/usr/bin directory

Ln-s/usr/local/python36/bin/python3.6/usr/bin/python

Adding the version python3.6.5 command to an environment variable

Vim/etc/profile

Export path= $PATH:/usr/local/python36/bin This sentence is added to the bottom of the file.

Source/etc/profile #刷新配置

That's it!

Of course not ~ ~ you will find Yum bad, because Yum is based on Python, and then Python3 is loaded, but for some reason can not find (specific Baidu bar), so the solution is as follows:

Vi/usr/bin/yum

#!/usr/bin/python modified into #!/usr/bin/python2.6.6

Yum performs validation

That's OK.

This time, there are two versions of Python, but the default is Python3

Using the Python3 installation library

PIP3 Install XXX

Download using Python2

Pip Install xxx

~~~~~~~~~~~~~~~~~~~~ is finished ~~~~~~~~~~~~~~~~~~~~~~~~~~

[linux]centos7.4 upgrade Python2 version to python3.6.5 "Install dual version, default Python3"

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.