Kali 2020.3中pip3安装requests失败:Python SSL模块缺失
Hey there, let's get this sorted out for you! The error you're hitting boils down to one core issue: your Python 3 installation doesn't have the SSL module enabled, which breaks pip's ability to connect to PyPI's HTTPS endpoints. Here's a step-by-step fix:
Step 1: Install Required System Dependencies
First, make sure your system has the foundational libraries needed for Python's SSL module to work. Run this as root:
apt update && apt install -y libssl-dev python3-dev python3-openssl
libssl-dev: Provides system-level OpenSSL development files that Python needs to link its SSL module.python3-dev: Ensures Python has the header files required to interface with system libraries.python3-openssl: Installs Python's official bindings for OpenSSL, which directly enables the missing SSL module.
Step 2: Reinstall Python 3 and Pip
Corrupted installations can sometimes cause this issue. Reinstalling these packages will reset them to a working state:
apt reinstall -y python3 python3-pip
Step 3: Verify the SSL Module is Working
Before trying to install requests again, confirm the fix worked with a quick check:
python3 -c "import ssl; print('SSL module loaded successfully! OpenSSL version:', ssl.OPENSSL_VERSION)"
If you see the OpenSSL version printed without errors, you're ready to move on.
Step 4: Install requests
Now try installing the requests library again:
pip3 install requests
Temporary Workaround (If Issues Persist)
If the SSL fix still doesn't work for some reason, you can use an HTTP PyPI mirror as a temporary stopgap (note: HTTPS is always safer for long-term use):
pip3 install requests -i http://pypi.org/simple/ --trusted-host pypi.org
Your Original Error Log for Reference
root@kali:~# pip3 install requests
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
警告:因'SSLError("无法连接HTTPS URL,因为SSL模块不可用")'导致连接中断,正在重试(Retry(total=4, connect=None, read=None, redirect=None, status=None)):/simple/requests/
警告:因'SSLError("无法连接HTTPS URL,因为SSL模块不可用")'导致连接中断,正在重试(Retry(total=3, connect=None, read=None, redirect=None, status=None)):/simple/requests/
警告:因'SSLError("无法连接HTTPS URL,因为SSL模块不可用")'导致连接中断,正在重试(Retry(total=2, connect=None, read=None, redirect=None, status=None)):/simple/requests/
警告:因'SSLError("无法连接HTTPS URL,因为SSL模块不可用")'导致连接中断,正在重试(Retry(total=1, connect=None, read=None, redirect=None, status=None)):/simple/requests/
警告:因'SSLError("无法连接HTTPS URL,因为SSL模块不可用")'导致连接中断,正在重试(Retry(total=0, connect=None, read=None, redirect=None, status=None)):/simple/requests/
无法获取URL https://pypi.org/simple/requests/:SSL证书验证出现问题:HTTPSConnectionPool(host='pypi.org', port=443):URL /simple/requests/的重试次数已达上限(由SSLError("无法连接HTTPS URL,因为SSL模块不可用")导致) - 跳过
ERROR: 找不到满足requests依赖的版本(可用版本:无)
ERROR: 未找到匹配的requests发行版
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
无法获取URL https://pypi.org/simple/pip/:SSL证书验证出现问题:HTTPSConnectionPool(host='pypi.org', port=443):URL /simple/pip/的重试次数已达上限(由SSLError("无法连接HTTPS URL,因为SSL模块不可用")导致) - 跳过
root@kali:~#
内容的提问来源于stack exchange,提问作者hydra-np

