1. 程式人生 > >centos 編譯 python3.7

centos 編譯 python3.7

轉:https://www.cnblogs.com/kimyeee/p/7250560.html

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 libffi-devel

2.下載Python3
  https://www.python.org/downloads/

1

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

3.安裝python3
  建立目錄:

1

# mkdir -p /usr/local/python3

1

# tar -zxvf Python-3.7.0.tgz

4.進入解壓後的目錄,編譯安裝。

1

2

# cd Python-3.7.0

# ./configure --prefix=/usr/local/python3

  make

1

# make

  make install

1

make install    或者 make && make install

5.建立python3的軟鏈

1

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

6.並將/usr/local/python3/bin加入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/python3/bin

export PATH

  按ESC,輸入:wq回車退出。

  修改完記得執行行下面的命令,讓上一步的修改生效:

1

# source ~/.bash_profile

  檢查Python3及pip3是否正常可用:

1

2

3

4

# python3 -V

Python 3.7.0

# pip3 -V

pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

7.不行的話在建立一下pip3的軟連結(我也不清楚這一步有什麼用)

1

# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3