虚拟环境中pip安装OpenCV时出现TLS协议版本错误求助
Hey there, let's work through this install error you're seeing. The root of the problem is two-fold:
- Your pip version is outdated, so it doesn't support the newer TLS protocols that PyPI now requires (PyPI dropped support for TLS 1.0/1.1 a while back)
- There's a corrupted pip cache entry that's causing extra issues
Here's how to fix it step by step:
Upgrade pip to the latest version first
Outdated pip is the main culprit here—newer versions use TLS 1.2+ which PyPI accepts. Run this in your TensorFlow virtual environment:pip install --upgrade pipIf you still hit SSL errors while upgrading pip, you can bypass the SSL check temporarily for this step (only do this once, as it's less secure):
pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.orgClear the corrupted pip cache
The "Cache entry deserialization failed" message means some cached data is broken. Clear the entire pip cache with:pip cache purgeInstall opencv-python again
Now that pip is updated and the cache is clean, try installing opencv-python once more:pip install opencv-pythonIf you're still facing network issues (like slow downloads or regional blocks), you can use a trusted domestic PyPI mirror by adding
-i [mirror URL]to the install command—look up reputable mirrors in your region for the exact address.
That should resolve both the SSL/TLS protocol error and the cache deserialization issue. Let me know if you run into any other snags!
内容的提问来源于stack exchange,提问作者Andy

