天天看點

centos7自帶python版本_Centos7安裝指定版本的Python

本文主要介紹在Centos7系統上如果安裝編譯指的Python版本,本例安裝Python-3.6.1

首先,為系統安裝所需的依賴庫,可根據具體使用情況安裝,如:yum install -y gcc zlib zlib-devel openssl-devel bzip2-devel openssl-devel sqlite-devel ncurese-devel

下載下傳源碼包:wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz

解壓安裝:# xz -d Python-3.6.1.tar.xz

# tar -xvf Python-3.6.1.tar

# cd Python-3.6.1/

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

# make && make install

建立指令軟連結:# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3

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

安裝相應模闆,根據需要安裝,如:pip3 install pymysql

pip3 install requests

pip3 install PyQuery

如果出現如下提示:You are using pip version 9.0.1, however version 18.0 is available.You should consider upgrading via the 'pip install --upgrade pip' command.

表可pip版本過低,可執行指令更新:# pip3 install --upgrade pip