安裝python3.x

1.安裝依賴環境python

1 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.下載python3.xsql

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

3.安裝pythonvim

1 建立目錄
2 mkdir -p /usr/local/python3
3 解壓縮
4 tar -zxvf Python-3.6.1.tgz
5 進入解壓縮目錄,編譯安裝
6 cd Python-3.6.1
7 ./configure --prefix=/usr/local/python3
8 make && make install
1 建立軟鏈接
2 ln -s /usr/local/python3/bin/python3 /usr/bin/python3

4.將python加入環境變量python3.x

1 # vim ~/.bash_profile
2 # .bash_profile
3 # Get the aliases and functions
4 if [ -f ~/.bashrc ]; then
5 . ~/.bashrc
6 fi
7 # User specific environment and startup programs
8 PATH=$PATH:$HOME/bin:/usr/local/python3/bin
9 export PATH
執行命令生效
source ~/.bash_profile

5.查看python和pip版本bash

# python3 -V
Python 3.6.1
# pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)
相關文章
相關標籤/搜索