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

猜你喜欢

转载自blog.csdn.net/ai_1046067944/article/details/82906512