zoukankan      html  css  js  c++  java
  • the ssl module in Python is not available错误解决

    在使用pip安装pymongo的过程中报错,提示如下:

    1 $ pip3 install pymongo
    2 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    3 Collecting pymongo
    4   Could not fetch URL https://pypi.python.org/simple/pymongo/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
    5   Could not find a version that satisfies the requirement pymongo (from versions: )
    6 No matching distribution found for pymongo

    这是由于缺少ssl模块,进入python中验证。

    $ python
    Python 3.7.0a3 (default, Jan 10 2018, 14:36:35)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
    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/lib/python3.7/ssl.py", line 100, in <module>
        import _ssl             # if we can't import it, let the error propagate
    ModuleNotFoundError: No module named '_ssl'
    >>>

    原因找到:缺少openssl-devel包

    $ rpm -qa | grep openssl
    openssl-1.0.2k-8.el7.x86_64
    xmlsec1-openssl-1.2.20-7.el7_4.x86_64
    openssl-libs-1.0.2k-8.el7.x86_64

    解决方法:

    1、安装openssl-devel包

    $ sudo yum install -y openssl-devel

    2、重新编译安装pyhton

    修改Setup配置

    $ vi Modules/Setup
    找到
    # Socket module helper for socket(2)
    #_socket socketmodule.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
    改为
    # Socket module helper for socket(2)
    _socket socketmodule.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

    编译安装

     ./configure &&  sudo make && sudo make install

    验证:

    $ python
    Python 3.7.0a3 (default, Jan 10 2018, 15:13:22)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ssl
    >>>

    安装pymongo

    $ sudo /usr/local/bin/pip3 install pymongo
    Collecting pymongo
      Downloading pymongo-3.6.0.tar.gz (581kB)
        100% |████████████████████████████████| 583kB 28kB/s
    Installing collected packages: pymongo
      Running setup.py install for pymongo ... done
    Successfully installed pymongo-3.6.0

    安装完成

  • 相关阅读:
    linux 消息队列
    linux 共享内存
    多线程(八)~ThreadLocal、InheritableThreadLocal的使用
    多线程(四)~数据操作的原子性,使用原子性操作AutomicInteger替换非原子性的i++的操作
    多线程(五)~ wait/notify机制(等待/通知)
    多线程(六)~通过管道进行线程之间的通信:字节流、字符流
    多线程(二)~Thread类相关的API介绍
    多线程(三)~多线程中数据的可见性-volatile关键字
    多线程(一)~基础介绍,简单demo实现
    haproxy学习——安装(一)
  • 原文地址:https://www.cnblogs.com/binbinyouni/p/8258980.html
Copyright © 2011-2022 走看看