Home  >  Article  >  Backend Development  >  Simple implementation of upgrading Centos Python2 to Python3

Simple implementation of upgrading Centos Python2 to Python3

WBOY
WBOYOriginal
2016-07-21 14:53:161165browse

1. Get the Python3 package from the Python official website and switch to the directory /usr/local/src

#wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz

2. Use the following command to decompress:

1 xz -d Python-3.5.1.tar.xz
2 tar -xf Python-3.5.1.tar.xz

3. Create a directory --python3.5 in the /usr/local path, which is the installation directory in step 4

$mkdir /usr/local/python3.5

4. Compile and install

$cd /usr/local/src/Python-3.5.1
#./configure --prefix=/usr/local/python3.5
#make all
#make install
#make clean
#make distclean

5. Enter the absolute path of the installation and check whether the installation is successful

$ /usr/local/python3.5/bin/python3.5 -V Python 3.5.1

6. Check the environment variables. When starting python, the search is performed in the order of PATH by default. The python in /usr/bin is Python2.6 at this time.

$echo $PATH
 /usr/lib/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/gordon/bin

7. Modify the soft connection and point to python3.5 when starting python

1 备份pythonmv /usr/bin/python /usr/bin/python2.6.6
2 修改软连接 sudo ln -s /usr/local/python3.5/bin/python3 /usr/bin/python

8. Verify whether python3.5 is started by default

$ python -V
 Python 3.5.1

The above simple implementation of upgrading Centos Python2 to Python3 is all the content shared by the editor. I hope it can give you a reference, and I hope you will support Script Home.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn