centos6.5系統下將Python2.6.6升級為Python3.5.0
阿新 • • 發佈:2018-12-26
- [[email protected] Python-3.5.0]# python
- Python 3.5.0 (default, Jul 15 2017, 07:13:36)
- [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
- Type "help", "copyright", "credits" or "license" for more information.
vim /usr/bin/yum
- #!/usr/bin/python python修改為 python2.6
- import sys
- try:
- import yum
- except ImportError:
- print >> sys.stderr, """\
- There was a problem importing one of the Python modules
- required to run yum. The error leading to this problem was:
- %s
- Please install a package which provides this module, or
- verify that the module is installed correctly.
- It's possible that the above module doesn't match the
- current version of Python, which is:
- %s
- If you cannot solve this problem yourself, please go to
- the yum faq at:
Centos6.5(64位)下安裝Python-3.5
執行./configure時報錯:
configure: error: no acceptable C compiler found in $PATH
***********************************************************
檢視得知未安裝合適的編譯器。解決辦法如下:
sudo yum install gcc-c++
(使用sudo yum install gcc-c++時會自動安裝/升級gcc及其他依賴的包。)
重新執行以下命令
./configure --prefix=/usr/local/python3.5
make
make install
成功!
附帶說明gcc與g++/gcc-c++的異同:
gcc為GNU Compiler Collection的縮寫,可以編譯C和C++原始碼等,它是GNU開發的C和C++以及其他很多種語言的編譯器(最早的時候只能編譯C,後來很快進化成一個編譯多種語言的集合,如Fortran、Pascal、Objective-C、Java、Ada、 Go等。)
gcc在編譯C++原始碼的階段,只能編譯C++原始檔,而不能自動和C++程式使用的庫連結(編譯過程分為編譯、連結兩個階段,源程式檔案被編譯成目標檔案,多個目標檔案連同庫被連結成一個最終的可執行檔案,可執行檔案被載入到記憶體中執行)。因此,通常使用g++命令來完成C++程式的編譯和連線,該程式會自動呼叫 gcc 實現編譯。
g++也能編譯C原始碼,只不過把會把它當成C++原始碼。字尾為.c的原始檔,gcc把它當作是C程式,而g++把它當作是c++程式;字尾為.cpp的,兩者都會認為是c++程式。注意,雖然c++是c的超集,但是兩者對語法的要求是有區別的。