How to fix: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

I have installed python3.11 on my new devbox, with system debian 9. Everything goes well, but when I using pip to install requirements, error occurs. The details are as follows.

➜  pip3 install virtualenv
Defaulting to user installation because normal site-packages is not writeable
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
Could not fetch URL https://pypi.org/simple/virtualenv/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/virtualenv/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement virtualenv (from versions: none)
ERROR: No matching distribution found for virtualenv
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
WARNING: There was an error checking the latest version of pip.

I think the key error message is: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available, and
Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")

I have made many efforts:

  • reinstall python with openssl according to Question: 57586800
  • install other requirements according to Question: 45954528
  • set trusted host, like:
    pip config set global.trusted-host 
        "pypi.org files.pythonhosted.org pypi.python.org" 
        --trusted-host=pypi.python.org 
        --trusted-host=pypi.org 
        --trusted-host=files.pythonhosted.org
    
    

Methods above don’t work for me. So I wonder what goes wrong?

More details:

  1. Before I compile python, I have run:
    • sudo apt install libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev libtk8.6 libgdm-dev libdb4o-cil-dev libpcap-dev to install ssl requirements (maybe?)
    • and then, I run the follow commands to install openssl.
    cd /usr/src 
    curl openssl.org/source/openssl-1.0.2o.tar.gz | tar xz 
    cd openssl-1.0.2o 
    ./config shared --prefix=/usr/local/ 
    sudo make 
    sudo make install
    
  2. I found the default python2.7 runs well, but python3 doesn’t
    ➜  ~ python3 -V
    Python 3.11.3
    ➜  ~ python3 -c "import ssl; print(ssl.OPENSSL_VERSION_INFO)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/local/lib/python3.11/ssl.py", line 100, in <module>
        import _ssl  # if we can't import it, let the error propagate
        ^^^^^^^^^^^
    ModuleNotFoundError: No module named '_ssl'
    ➜  ~ python -V
    Python 2.7.13
    ➜  ~ python -c "import ssl; print(ssl.OPENSSL_VERSION_INFO)"
    (1, 1, 0, 12, 15)
    
  3. The openssl version that python3.10+ needs should be greater than 1.1.1(Note PEP-644 which requires OpenSSL >= 1.1. 1 is released in Python 3.10
    )? But the openssl in my Debian9 is 1.0.2o.

    ➜  which openssl
    /usr/local/bin/openssl
    ➜  openssl version
    OpenSSL 1.0.2o  27 Mar 2018
    

    I have upgraded openssl to 3.0 and rebuild python3.10, also doesn’t work.

  4. Using pyenv to install python also doesn’t. Error, ‘_ssl’ requirement is not satisfied, occurs.

=========================================

Finally, I reinstall the system from debian9 to debian10. The default openssl version is OpenSSL 1.1.1n. All errors disappear.

The problem is fixed.

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật