签到成功

知道了

CNDBA社区CNDBA社区

Python3.7无法正常导入ssl--ImportError: No module named _ssl

2018-11-01 15:01 7549 0 原创 python开发
作者: Expect-乐

1.说明

在升级到python3.7后,发现pip无法正常安装模块,报错信息如下:

http://www.cndba.cn/Expect-le/article/3108
http://www.cndba.cn/Expect-le/article/3108http://www.cndba.cn/Expect-le/article/3108http://www.cndba.cn/Expect-le/article/3108

>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python37/lib/python3.7/ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named _ssl

2.解决方法

2.1修改Setup.dist文件

[root@storage2 ~]# vi /root/Python-3.7.1/Modules/Setup.dist

http://www.cndba.cn/Expect-le/article/3108
http://www.cndba.cn/Expect-le/article/3108
http://www.cndba.cn/Expect-le/article/3108http://www.cndba.cn/Expect-le/article/3108
http://www.cndba.cn/Expect-le/article/3108

2.2修改结果如下:

将下面原本注释掉的内容给取消注释即可,一共四行http://www.cndba.cn/Expect-le/article/3108

# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c /
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl /

2.3重新编译安装

[root@storage2 Python-3.7.1]#./configure --prefix=/usr/local/python37
[root@storage2 Python-3.7.1]#make
[root@storage2 Python-3.7.1]#make install

版权声明:本文为博主原创文章,未经博主允许不得转载。

ImportError: No module named _ssl

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Expect-乐

Expect-乐

关注

Without the continuous bitter cold, there can be no fragrant plum blossom

  • 336
    原创
  • 6
    翻译
  • 100
    转载
  • 41
    评论
  • 访问:1374608次
  • 积分:1957
  • 等级:核心会员
  • 排名:第3名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ