在linux上安裝python3

2022-02-25 01:12:50 字數 1308 閱讀 8863

我們原裝的centos上是有python2.7的,不建議刪除,可以做個python3共存的。

# python

python 2.7.5 (default, nov 20 2015, 02:00:19)

[gcc 4.8.5 20150623 (red hat 4.8.5-4)] on linux2

>>>

# which python

/usr/bin/python

可以檢視位置,一般是位於/usr/bin/python目錄下。

首先安裝依賴包,這個比較多,我這裡寫的的比較全,要是有時候make或者make install 出現問題,大部分都是依賴包缺失或者損壞,需要一次性安好。

# yum -y groupinstall "development tools"

# 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

# yum -y install gcc gcc-c++ zlib zlib-devel libffi-devel

# wget 

# tar -xvf python-3.7.0b3.tgz

# cd python-3.7.0b3/

# ./configure --prefix=/data/soft/python/

# make && make install

# ln -s /data/soft/python/bin/python3 /data/soft/python3

# ln -s /data/soft/python/bin/pip3 /data/soft/pip3

# vim /etc/profile

加入下面兩行

path=/data/soft/python/bin:/data/soft/python/lib:$path

export path

# source /etc/profile

# python3

python 3.7.0b3 (default, may 2 2018, 13:55:41)

[gcc 4.8.5 20150623 (red hat 4.8.5-16)] on linux

>>>

大功告成,寫完收工!!! 

在linux上安裝python3

bin bash echo 正在安裝依賴軟體包 請稍等.yum y install gcc gcc c make zlib devel bzip2 devel openssl devel sqlite devel readline devel libffi devel wget dev null i...

在Linux上安裝Python3

一 安裝依賴環境 輸入命令 yum y install zlib devel bzip2 devel openssl devel ncurses devel sqlite devel readline devel tk devel gdbm devel db4 devel libpcap devel...

在Linux上安裝Python3

在linux上安裝python3 一 安裝依賴環境 yum y install zlib devel bzip2 devel openssl devel ncurses devel sqlite devel readline devel tk devel gdbm devel db4 devel l...