如何在已經存在python2的linux環境上安裝python3


最近看到好多人都在問在已經存在python2.7的環境下如何安裝python3,於是我決定寫下這篇文檔,供大家學習參考,希望能夠給大家帶來幫助

有的人在安裝的時候可能會先將python2卸載掉,這個地方嚴重強調一下,不要去卸載系統中已經存在的python2,否則會造成系統中好多其他需要python執行的程序異常

  • 系統環境
[root@localhost install]# pwd
/data/install

[root@localhost install]# cat /etc/redhat-release 
CentOS release 6.3 (Final)

[root@localhost install]# uname -a
Linux localhost 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
  • python3.4的安裝方法
[root@localhost install]# wget https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz
[root@localhost install]# tar -zxf Python-3.4.4.tgz
[root@localhost install]# cd Python-3.4.4

# 在安裝包中有一個README的文件,里面有寫如何安裝
[root@localhost Python-3.4.4]# ls
aclocal.m4    config.sub  configure.ac  Grammar  install-sh  LICENSE  Makefile.pre.in  Modules  Parser  PCbuild        Python  setup.py
config.guess  configure   Doc           Include  Lib         Mac      Misc             Objects  PC      pyconfig.h.in  README  Tools

[root@localhost Python-3.4.4]# ./configure
[root@localhost Python-3.4.4]# make
[root@localhost Python-3.4.4]# make install
  • 測試
[root@localhost Python-3.4.4]# python3
Python 3.4.4 (default, Jun 27 2016, 07:47:54) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

以后執行python程序就可以使用python3 程序名 去執行了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM