python 3.6.5编译安装_Centos7下编译安装python3.6.5
一、下載源碼包并編譯安裝[root@iZtmm4mufhb0rgZ?/]#?wget??https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
[root@iZtmm4mufhb0rgZ?/]#?tar?xzvf?Python-3.6.5.tgz
[root@iZtmm4mufhb0rgZ?/]#?cd?Python-3.6.5
[root@iZtmm4mufhb0rgZ?/]#??./configure?--enable-shared?--prefix=/usr/local?CFLAGS=-fPIC?LDFLAGS="-Wl,-rpath?/usr/local/lib"?--with-ssl
[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?make?-j24?&&?make?install
-------------------------安裝成功---------------------------------
Collecting?pip
Installing?collected?packages:?setuptools,?pip
Successfully?installed?pip-9.0.3?setuptools-39.0.1
二、添加程序的軟連接
自3.4版本起,setup_tools及pip工具自動安裝,所以不用再手動安裝了[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?sudo?ln?-sf?/usr/local/bin/python3.6?/usr/bin/python3
[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?sudo?ln?-sf?/usr/local/bin/python3.6?/usr/bin/python3.6
[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?sudo??ln?-sf?/usr/local/bin/pip3.6?/usr/bin/pip3
[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?sudo??ln?-sf?/usr/local/bin/pip3.6?/usr/bin/pip3.6
遇到的錯誤以及解決方法:
第一個坑:編譯安裝時報以下錯誤zipimport.ZipImportError:?can't?decompress?data;?zlib?not?available
make:?***?[install]?Error?1
-------------------------------------------------------------------
[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?yum?install?-y?zlib*????????##解決辦法;安裝zlib軟件包重新編譯即可
第二個坑:執行命令報錯
這兩類是一個錯誤,因為庫不在pyhon3這個程序可以正確連接的地方[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?sudo?python3
python3:?error?while?loading?shared?libraries:?libpython3.6m.so.1.0:?cannot?open?shared?object?file:?No?such?file?or?directory
[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?sudo?pip3?install?numpy
/usr/local/bin/python3.6:?error?while?loading?shared?libraries:?libpython3.6m.so.1.0:?cannot?open?shared?object?file:?No?such?file?or?directory
有兩種解決方案,一種是在./configure加入LDFLAGS="-Wl,-rpath /usr/local/lib" 手動指定,另一種是設定全局變量LD_LIBRARY_PATH。顯然第一種方案更好一些,第二種方案導致普通用戶程序感染root程序的執行,危害很大。
第三個坑:使用pip安裝模塊時提示找不到ssl模塊
原因是:在./configure過程中,如果沒有加上–with-ssl參數時,默認安裝的軟件涉及到ssl的功能不可用,剛好pip3過程需要ssl模塊,而由于沒有指定,所以該功能不可用。pip?is?configured?with?locations?that?require?TLS/SSL,?however?the?ssl?module?in?Python?is?not?available.
Could?not?fetch?URL?https:*******:?There?was?a?problem?confirming?the?ssl?certificate:
Can't?connect?to?HTTPS?URL?because?the?SSL?module?is?not?available.?-?skipping
------------------------------------------------------------------------
##解決辦法;./configure時加上--with-ssl選項
##解決辦法2:缺少依賴包?yum?install?zlib-devel?bzip2-devel?openssl-devel?ncurses-devel?sqlite-devel?readline-devel?tk-devel
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的python 3.6.5编译安装_Centos7下编译安装python3.6.5的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 编程 中文等宽_UG编程经典教程
- 下一篇: python下载图片、已知url_pyt