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工具自動(dòng)安裝,所以不用再手動(dòng)安裝了[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
遇到的錯(cuò)誤以及解決方法:
第一個(gè)坑:編譯安裝時(shí)報(bào)以下錯(cuò)誤zipimport.ZipImportError:?can't?decompress?data;?zlib?not?available
make:?***?[install]?Error?1
-------------------------------------------------------------------
[root@iZtmm4mufhb0rgZ?Python-3.6.5]#?yum?install?-y?zlib*????????##解決辦法;安裝zlib軟件包重新編譯即可
第二個(gè)坑:執(zhí)行命令報(bào)錯(cuò)
這兩類是一個(gè)錯(cuò)誤,因?yàn)閹?kù)不在pyhon3這個(gè)程序可以正確連接的地方[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" 手動(dòng)指定,另一種是設(shè)定全局變量LD_LIBRARY_PATH。顯然第一種方案更好一些,第二種方案導(dǎo)致普通用戶程序感染root程序的執(zhí)行,危害很大。
第三個(gè)坑:使用pip安裝模塊時(shí)提示找不到ssl模塊
原因是:在./configure過程中,如果沒有加上–with-ssl參數(shù)時(shí),默認(rèn)安裝的軟件涉及到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時(shí)加上--with-ssl選項(xiàng)
##解決辦法2:缺少依賴包?yum?install?zlib-devel?bzip2-devel?openssl-devel?ncurses-devel?sqlite-devel?readline-devel?tk-devel
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的python 3.6.5编译安装_Centos7下编译安装python3.6.5的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 编程 中文等宽_UG编程经典教程
- 下一篇: python下载图片、已知url_pyt