如何安裝python3
1 準備工作
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel
yum install -y zlib*
2 安裝
0 cd /usr/local/software
1 wget https://www.python.org/ftp/python/3.6.2/Python-2 3.6.2.tar.xz
3 tar -xvJf Python-3.6.2.tar.xz
4 cd Python-3.6.2
5 修改Modules/Setup.dist
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c . # 去掉此行的註釋
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl # 去掉此行的註釋
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
6 ./configure prefix=/usr/local/python3
7 yum install -y zlib*
8 make && make install
3 將python3添加到環境變量中
vim ~/.bash_profile
[root]# cat ~/.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]# source ~/.bash_profile
4 確認安裝是否成功
[root]#which python3
/usr/local/python3/bin/python3
安裝完成!!