CentOS 升級Python3.X&pip3__Python

來源:互聯網
上載者:User

前言:

  我目前使用的伺服器為centos6.x 系統內建的python的版本為2.6.x,但是目前無論是學習還是使用python,python3都是首選,那麼問題來了。---如何安裝python3環境,又如何給python3安裝對應的pip3呢。 更關鍵的是我們原來的系統中還有一些內建的工具需要用到python2.6版本,所以要求的是python3 and python2 共存,pip2 and pip3共存。下面文章就是我的親自實踐。(給 python3 安裝 pip3) 0、安裝依賴

yum install openssl-devel   -yyum install zlib-devel  -y
一、安裝python3

1:下載 安裝包:

wget http://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz 

2:解壓安裝包:
tar -zxvf Python-3.4.3.tgz  
3:進入解壓後目錄:
cd Python-3.4.3
4:建立安裝目錄:
mkdir /usr/local/python3.4   
5:編譯安裝:
./configure –prefix=/usr/local/python3.4
6:執行:
make && make install
7:此時已完成新版本的安裝,但由於老版本還在系統中,所以需要將原來/usr/bin/python連結改為新的串連:a.先修改老的串連,執行:mv /usr/bin/python /usr/bin/python_bak。b.再建立新串連: ln -s /usr/local/python3.4/bin/python3.4 /usr/bin/python (建議不要這樣做,會導致yum工具不能使用,最好建議產生軟串連python3)
7.ln -s /usr/local/python3.4/bin/python3.4 /usr/bin/python3(推薦)
8:查詢python版本,執行:
python3
Python 3.4.3 (default, Nov 9 2016, 14:41:47) 二、安裝pip3

1:安裝依賴

yum install openssl-devel   -yyum install zlib-devel  -y

2:安裝setuptools

wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26tar -zxvf setuptools-19.6.tar.gzcd setuptools-19.6.tar.gzpython3 setup.py buildpython3 setup.py install

3:安裝pip

wget --no-check-certificate  https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eebtar -zxvf pip-8.0.2.tar.gzcd pip-8.0.2python3 setup.py buildpython3 setup.py install

ref:http://www.cnblogs.com/wenchengxiaopenyou/p/5709218.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.