Linux編譯安裝Python3

依賴安裝:

yum install gcc zlib zlib-devel libffi-devel readline readline-devel openssl openssl-devel
  1. gcc:編譯依賴
  2. readline:解決python命令行中刪除鍵無效的問題
  3. openssl:解決pip3安裝python包報錯的問題:下面是對應的報錯信息
pip3 is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

下載python:

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

   這裏以python3.5爲例,也能夠選擇其餘的版本。python

安裝:

  解壓:

tar -xvf Python-3.5.0.tgz   # 解壓到當前目錄

  進入解壓目錄:

cd Python-3.5.0

  指定安裝目錄:

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

  編譯並安裝:

make && make install

  檢驗是否成功:

/usr/local/python3.5/bin/python3   # 回車進入python3.5命令行

  建立軟連接:

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

 

而後在任意目錄使用python3命令就能夠進入python3.5的命令行。 ui

相關文章
相關標籤/搜索