Linux installation steps python3.x

linux system itself is installed by default 2.x version of python, version x vary depending on the version of the system, --version view the system comes with python version by python --V or python.

There are some systems need to use command python2, can not uninstall, but the actual development is often python3, so the installation process python3 in this record, paper python3.7.0 as an example.

First, install dependencies                                                                       

1, first install gcc compiler, gcc versions of some systems already installed by default, --version viewed by gcc, not installed install gcc, yum -y install gcc

2, install additional dependencies, (Note: Do not missing, or they may install python error, python3.7.0 less time to install version libffi-devel)

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

Second, download python3.7.0 source, according to the needs download

1, in https://www.python.org/ftp/python/ choose their own needs python source package, I downloaded the python3.7.0 (you can also go https://www.python.org official web page download find downloads, you can select the version you want to download).

2. Download the

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

3, extract the Python-3.7.0.tgz

tar -zxvf Python-3.7.0.tgz

4, create an empty folder, used to store programs python3        

mkdir /usr/local/python3

5, to perform the configuration file, compile, build and install            

cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install

No error will be prompted to complete the installation successfully installed

6, the establishment of flexible connections                     

ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3

7, can be used to test whether python3              

[root@mini Python-3.7.0]# python3
Python 3.7.0 (default, Jul 28 2018, 22:47:29) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world!")
hello world!
>>> exit()
[root@mini Python-3.7.0]# pip3 --version
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

Can be used normally see python3.7.0

Published 106 original articles · won praise 47 · views 130 000 +

Guess you like

Origin blog.csdn.net/qq493820798/article/details/101774346