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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值