Simple implementation of upgrading Centos Python2 to Python3

WBOY
Release: 2016-07-21 14:53:16
Original
1213 people have browsed it

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
Copy after login

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
Copy after login

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

$mkdir /usr/local/python3.5
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

8. Verify whether python3.5 is started by default

$ python -V
 Python 3.5.1
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template