centOS安裝python3 以及解決 導入ssl包出錯的問題

 

參考:html

http://www.javashuo.com/article/p-kdwmpyqh-ev.htmljava

http://www.javashuo.com/article/p-mfmjnnzo-es.htmlpython

確認環境 系統版本c++

openssl版本sql

[root@67 local]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017spa

OPS,竟然新安裝的centOS系統自帶的就是1.0.2版本,這是否是意味着我能夠很輕鬆的安裝好python,而後import ssl就不會報錯,而不用再去額外配置openssl了呢3d

?期待的搓搓手(緣由是python3須要要注意的地方是版本要1.02以上版本才能正常使用像requests之類的庫)code

 

爲了不後面報各類錯,咱們先把須要的信賴包安裝上,再安裝python3sqlite

執行完make&&make install以後,可能會出現這種報錯:htm

「ModuleNotFound:No module named '_ctypes'」

這裏須要執行:

yum install libffi-devel -y


安裝python3.6可能使用的依賴
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++  openssl-devel
 

[root@67 local]# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64 already installed and latest version
Package bzip2-devel-1.0.6-13.el7.x86_64 already installed and latest version
Package expat-devel-2.1.0-10.el7_3.x86_64 already installed and latest version
Package gdbm-devel-1.10-8.el7.x86_64 already installed and latest version
Package readline-devel-6.2-10.el7.x86_64 already installed and latest version
Package sqlite-devel-3.7.17-8.el7.x86_64 already installed and latest version
Package gcc-4.8.5-36.el7_6.2.x86_64 already installed and latest version
Package gcc-c++-4.8.5-36.el7_6.2.x86_64 already installed and latest version
Package 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64 already installed and latest version
Nothing to do
[root@67 local]# yum install libffi-devel -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package libffi-devel-3.0.13-18.el7.x86_64 already installed and latest version

 

 

下面開始安裝,太緊張了
 

創建一個文件夾安裝python3

mkdir /usr/local/python3

 

下載安裝文件

下載
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz

 

 

解壓

tar -xf Python-3.6.2.tgz

 

進入目錄

cd Python-3.6.2

 

安裝python3 (要注意若是你的ssl也是指定目錄安裝的 --with要跟上路徑)

./configure --prefix=/usr/local/python3 --with-ssl

 

編譯,安裝,這一步會花的時間長一點

make && make install

 

 安裝完成

建立軟鏈接以前先驗證一下環境

cd /usr/local/python3/bin/

 

cd /usr/bin

 

 

最後建立軟鏈接

ln -s /usr/local/python3/bin/python3 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

創建軟連接後

接下來就是要驗證的時候,太牢牢緊張了

驗證經過了~ 激動呀 開心呀,上次在centOS6.5搞這一套流程,一直有問題,整了週五下午到凌晨3點,週六下午7點到凌晨1點,整我的都很差了.

竟然重裝一次系統就解決問題了.

centOS7.6 自帶的openSSL版本就能夠支持python3了,無須再作配置,這真是省了好多心呀

 

相關文章
相關標籤/搜索