Impala(四):Python3.6連接Impala的No module named _ssl

1、問題描述: Python3.6連接Impala的No module named _ssl

Python2是沒有這個問題的

>>> from impala.dbapi import connect
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python36/lib/python3.6/ssl.py", line 60, in <module>
import _ssl
ImportError: No module named _ssl
>>>

2、解決方案

a  安裝python3依賴的openssl-devel包 

Linux:

RedHat系列: RedHat、Centos、Fedora

> yum install openssl-devel

PS: 安裝工具—— rpm、yum、tar

Debian系列:Debian、Ubuntu
> sudo apt-get install openssl

> sudo apt-get install libssl-dev

PS: 安裝工具—— apt-get、dpkg、tar
 

b  修改python3.6源碼

#修改Setup文件
> vi Python-3.6.5/Modules/Setup.dist

206 # CSV file helper
207 #_csv _csv.c
208
209 # Socket module helper for socket(2)
210 _socket socketmodule.c
211
212 # Socket module helper for SSL support; you must comment out the other
213 # socket line above, and possibly edit the SSL variable:
214 #SSL=/usr/local/ssl
215 _ssl _ssl.c \
216     -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
217     -L$(SSL)/lib -lssl -lcrypto
218
219 # The crypt module is now disabled by default because it breaks builds
220 # on many systems (where -lcrypt is needed), e.g. Linux (I believe).
221 #
222 # First, look at Setup.config; configure may have set this for you.
223
224 #crypt cryptmodule.c # -lcrypt  # crypt(3); needs -lcrypt on some systems

c 重新編譯

> cd ./Python-3.6.5
> ./configure
> make
> make install

d 解決

>>> from impala.dbapi import connect
ok

3、參考文獻:

python3安裝過程中出現的ssl問題No module named _ssl: https://blog.csdn.net/chief_victo/article/details/80425431Compiling

Python with SSL Support: http://www.webtop.com.au/blog/compiling-python-with-ssl-support-fedora-10-2009020237

 

==========================================================================================

python2在安裝impyla時,依賴包bitarray、thrift,有時候會報: bitarray error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

需要apt-get install python-dev可以解決,同時python2下,安裝pip install thrift ==0.9.3

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