CentOS 7 install Python3.6 process

  CentOS 7 system comes with python2, but you can run python scripts directly with python3 without using version 2, but don't understand the python2 that comes with the system, because there are programs that depend on the current python2 environment, such as yum! ! ! ! ! If you move yum, it will not work, and some other programs may also be affected. Understand the above, and then install Python3.6:

installation steps:

1. Install dependencies

  # 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

2. Download Python3
  https://www.python.org/downloads/

1
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

3. Install python3

  The package is installed in /usr/local/Python3 (the specific installation location depends on personal preference)
  to create a directory:

1
# mkdir -p /usr/local/Python3

  Unzip the downloaded Python-3.6.5.tgz package (the specific package name depends on the specific version of Python you downloaded, I downloaded Python3.6.5, here is Python-3.6.5.tgz as an example)

1
# tar -zxvf Python-3.6.5.tgz

4. Enter the decompressed directory, compile and install. (If there is an error message during the compilation and installation process, see another solution I wrote in my essay http://www.cnblogs.com/shwee/p/9013851.html)

1
2
# cd Python-3.6.5
# ./configure --prefix=/usr/local/Python3

  After that: make

1
# make

  Next: make install

1
make install    或者 make && make install

5. After installation, create a soft chain of python3

1
# ln -s /usr/local/Python3/bin/python3 /usr/bin/python3

6. Add /usr/local/Python3/bin to PATH

1
2
3
4
5
6
7
8
9
# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if  - f ~ / .bashrc ]; then
. ~ / .bashrc
fi
# User specific environment and startup programs
PATH = $PATH:$HOME / bin : / usr / local /P ython3 / bin
export PATH

  Press ESC, enter: wq, press Enter to save and exit editing.

  After the modification, remember to execute the following command to make the modification in the previous step take effect:

1
# source ~/.bash_profile

  Check whether Python3 and pip3 are available normally:

1
2
3
4
# python3 -V
Python  3.6 . 1
# pip3 -V
pip  9.0 . 1  from  / usr / local / python3 / lib / python3. 6 / site - packages (python  3.6 )

7. If pip3 cannot be viewed, create a soft link for pip3

1
# ln -s /usr/local/Python3/bin/pip3 /usr/bin/pip3

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326357981&siteId=291194637
Recommended