WSL环境使用pip报错:AttributeError: module 'lib'无X509_V_FLAG_CB_ISSUER_CHECK属性
WSL中pip损坏后的无pip依赖修复方案
方法1:通过系统包管理器重装Python及pip
针对WSL基于的Linux发行版(如Ubuntu、Debian),直接用系统包管理器操作,完全绕开损坏的pip:
- 卸载现有Python相关组件:
sudo apt purge python3-pip python3-setuptools python3-wheel sudo apt autoremove sudo apt clean - 重新安装完整环境:
sudo apt update sudo apt install python3 python3-pip python3-setuptools python3-wheel
方法2:手动用官方脚本重装pip
如果需要指定pip版本,用官方离线安装脚本,不依赖现有pip:
- 下载安装脚本(若无curl,先执行
sudo apt install curl):curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - 强制重装pip:
sudo python3 get-pip.py --force-reinstall
方法3:手动删除损坏的依赖包
如果是特定第三方包(如cryptography)导致的openssl相关错误,直接删除包文件:
- 查找Python的site-packages目录:
python3 -c "import site; print(site.getsitepackages())" - 删除对应损坏包(替换
3.x为你的Python版本):sudo rm -rf /usr/local/lib/python3.x/site-packages/cryptography*
删除后再用上述方法修复pip。
内容的提问来源于stack exchange,提问作者nordlad
相关产品推荐
相关产品推荐

