Linux-安装python3环境

Linux-安装python3环境

[root@node1 ~]# yum -y groupinstall "Development tools"

[root@node1 ~]# 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

[root@node1 ~]# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

[root@node1 ~]# mkdir -p /usr/local/python3
[root@node1 ~]# tar -zxf Python-3.6.1.tgz
 
[root@node1 ~]# cd Python-3.6.1
[root@node1 Python-3.6.1]# 
[root@node1 Python-3.6.1]# 
[root@node1 Python-3.6.1]# ls
aclocal.m4    configure     Grammar     Lib      Makefile.pre.in  Objects  PCbuild        Python      Tools
config.guess  configure.ac  Include     LICENSE  Misc             Parser   Programs       README.rst
config.sub    Doc           install-sh  Mac      Modules          PC       pyconfig.h.in  setup.py
[root@node1 Python-3.6.1]# ./configure --prefix=/usr/local/python3
[root@node1 Python-3.6.1]# make && make install
[root@node1 Python-3.6.1]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
 

 [root@node1 Python-3.6.1]# 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/python3/bin

export PATH

[root@node1 Python-3.6.1]# source ~/.bash_profile

[root@node2 Python-3.6.1]# pip3 install --upgrade pip

Collecting pip
  Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 155kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-19.1.1

[root@node1 Python-3.6.1]# python3 -V

Python 3.6.1

[root@node1 Python-3.6.1]# pip3 -V

pip 19.1.1 from /usr/local/python3/lib/python3.6/site-packages/pip (python 3.6) #这里如果没有显示不用执行下面命令

[root@node1 Python-3.6.1]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

这样就安装完成了

原文地址:https://www.cnblogs.com/kingzhe/p/11124527.html