“ssl module in Python is not available” when installing package with pip3

后端 未结 28 1941
别跟我提以往
别跟我提以往 2020-11-22 08:51

I\'ve install Python 3.4 and Python 3.6 on my local machine successfully, but am unable to install packages with pip3.

When I execute pip3 install

28条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 09:09

    I had the same issue with python3.8.5 installation on Debian9. I have done a build, but when I have tried to download some modules, pip3.8 issued following error:

    pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    

    I have searched for the root of my problem and found out that there is a system dependent portion of the python build which is called by system independent one. In case of missing ssl you just needed to open python terminal and check whether is _ssl present:

    >>> help('modules')
    .
    .
    _sre                enum                pwd                 wave
    _ssl                errno               py_compile          weakref
    _stat               faulthandler        pyclbr              webbrowser
    .
    .
    

    If not your system dependent ssl module part is missing. You can check it also by listing content of /lib/python3.8/lib-dynload:

    >ls ./lib/python3.8/lib-dynload | grep ssl
    _ssl.cpython-38-x86_64-linux-gnu.so
    

    The problem was caused as written by PengShaw by missing libssl-dev during the build. Therefore you have to follow the recommended python installation flow. First install prerequisites and then build and install the python. Installation without devel versions of libs resulted in my case in the missing system dependent part. In this case _ssl.

    Note that the devel lib name differs for Debian and CentOS, therefore check whether the installation hints posted on net are suitable for your specific Linux system type:

    For Debian:
    sudo apt install -y libbz2-dev libffi-dev libssl-dev
    ./configure --enable-optimizations
    make
    make altinstall
    
    
    For CentOS:
    sudo yum -y install bzip2-devel libffi-devel openssl-devel
    ./configure --enable-optimizations
    make
    make altinstall
    

    It is for sure a good idea to list configuration options prior the configuration and evtl. use some additional options:

    ./configure --help
    

    Last but not least in case you use --prefix for a non-default installation location, remember to add your /lib to your LD_LIBRARY_PATH .

提交回复
热议问题