下Linux下安裝Python

1.在官網上下載Python的Linux源碼包

2.解壓源碼包,在下載文件夾中解壓就可以了,安裝的時候系統會自動安裝到默認的應用目錄

3.在解壓後的文件夾中執行 ./configure 命令







最後會提示生成了 MakeFIle文件

補:configure 命令執行完之後,會生成一個 Makefile 文件,這個 Makefile主要是被下一步的 make 命令所使用。打開 Makefile你就會發現,裏邊制定了構建的順序, Linux 需要按照Makefile 所指定的順序來構建 (build) 程序組件。

4.執行 make 命令,生成可執行文件


5.執行 make install  命令

make install實際上是把生成的執行文件拷貝到 linux系統中必要的目錄下,比如拷貝到 /usr/local/bin 目錄下,這樣所有 user就都能運行這個程序了。

以上2-5步驟,是安裝源碼包的一般步驟

cent os7上安裝的時候遇到的問題:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking for --without-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/data/python/Python-2.7.8':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details


查了一下,發現有一種可能是沒有安裝gcc編譯器,查看了一下本機
gcc -v
果然沒有安裝gcc編譯器,所以先執行
yum install gcc 安裝一下再去執行安裝python

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章