zoukankan      html  css  js  c++  java
  • ubuntu下安装python3.6.5导入ssl模块失败

    1、问题

    python安装完毕后,提示找不到ssl模块:
    [root@localhost ~]# python3
    Python 3.6.5 (default, Jun 3 2018, 11:08:43) 
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ssl
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/python27/lib/python2.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、解决

    修改Python-3.6.5文件夹中的/Moudes/Setup.dict

    # 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   #去除该行注释(备注)
    -L$(SSL)/lib -lssl -lcrypto         #去除该行注释(备注)

    重新编译

    make
    sudo make install

    再进入python3交互模式,import ssl就可以了。

  • 相关阅读:
    while,do while和for循环语句的用法
    阶乘
    java--测体重练习
    java---相亲练习
    java ---运算符
    java数据类型定义与输出
    基本Java数据类型
    揭开UTF-8的神秘面纱
    POJ 1164 城堡问题【DFS/位运算/种子填充法/染色法】
    POJ 3984 迷宫问题【BFS/路径记录/手写队列】
  • 原文地址:https://www.cnblogs.com/xypbk/p/9007893.html
Copyright © 2011-2022 走看看