在Linux上安裝Python3

2022-09-19 18:33:12 字數 1492 閱讀 7921

在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 xz-devel
1.進入opt檔案目錄下,cd opt/

wget
3.安裝python3

(1)建立目錄:

4.進入解壓後的目錄,編譯安裝。(編譯安裝前需要安裝編譯器yum install gcc)

(1)安裝gcc    

yum install gcc -y
(2)3.7版本之後需要乙個新的包libffi-devel

安裝即可:

yum install libffi-devel -y
(3)進入python資料夾,生成編譯指令碼(指定安裝目錄):

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

#/usr/local/python3為上面步驟建立的目錄

(4)編譯:

make
(5)編譯成功後,編譯安裝:

make install
(6)檢查python3.7的編譯器:

5.建立python3和pip3的軟鏈:

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

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

6.並將/usr/local/python3/bin加入path

(1)vim /etc/profile

(2)按「i」,然後貼上下面內容:

# 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

(3)按esc,輸入:wq回車退出。

source ~/.bash_profile

7.檢查python3及pip3是否正常可用:

python3 -v

pip3 -v

在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

我們原裝的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 pyth...

在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...