You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Python3.6虚拟环境执行get-pip.py安装pip时遇WinError31错误求助

Fixing WinError 31 When Installing Pip in Python 3.6 Virtual Environment

Hey there, let's work through that frustrating WinError 31 you're hitting when trying to install pip in your myvenv_python3 virtual environment. I've dealt with similar Windows-specific glitches before, so here are actionable steps to resolve this:

1. Refresh Your Virtual Environment

Corrupted virtual environments can cause weird device-related errors. Let's start fresh:

  • First, exit your current virtual environment:
    deactivate
    
  • Delete the existing environment (use the command matching your terminal):
    • Command Prompt:
      rmdir /s myvenv_python3
      
    • PowerShell:
      Remove-Item -Recurse -Force myvenv_python3
      
  • Recreate the virtual environment:
    python -m venv myvenv_python3
    
  • Activate it again:
    myvenv_python3\Scripts\activate
    
  • Now re-run your get-pip.py command.

2. Use a Stable PyPI Mirror for Downloads

The error might stem from unstable connections to the official PyPI servers. Switch to a reliable mirror to avoid download interruptions:

python get-pip.py --trusted-host=pypi.org --trusted-host=pypi.python.org --trusted-host=files.pythonhosted.org -i https://pypi.tuna.tsinghua.edu.cn/simple

3. Check File Location and System Permissions

WinError 31 often ties to external storage devices or insufficient permissions:

  • If you're running get-pip.py from an external drive (like a USB stick), move the file to your local C: drive (e.g., C:\Users\Kaleab\Documents) and try again.
  • Launch your terminal as Administrator (right-click Command Prompt/PowerShell > "Run as administrator") before executing the install command—this ensures you have full access to system resources.

4. Manually Install Pip via Wheel Package

If the above steps fail, bypass the online download by manually installing the pip wheel:

  1. Download the pip 10.0.1 wheel file (pip-10.0.1-py2.py3-none-any.whl) to your local machine.
  2. Navigate to the folder containing the wheel file in your activated virtual environment, then run:
    python -m pip install pip-10.0.1-py2.py3-none-any.whl
    
    (If you don't have pip at all yet, use python -m wheel install pip-10.0.1-py2.py3-none-any.whl instead—ensure you have the wheel package installed first, or include it in your get-pip.py command.)

内容的提问来源于stack exchange,提问作者Kaleab Woldemariam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:28:57