Skip to content

Conversation

@yzbf-lin
Copy link
Contributor

@yzbf-lin yzbf-lin commented Sep 8, 2025

在subprocess.check_call()中添加shell=True参数,解决Windows系统下 执行python.exe ensurepip --upgrade时出现CalledProcessError(returncode 2)的问题

🔧 Technical Details

Before:

subprocess.check_call([
    'D:\\path\\to\\.venv\\Scripts\\python.exe',
    '-m','ensurepip','--upgrade'
])
# ❌ Fails with CalledProcessError (returncode 2)

**Afater:**
subprocess.check_call([
    'D:\\path\\to\\.venv\\Scripts\\python.exe',
    '-m','ensurepip','--upgrade'
], shell=True)
# ✅ Works correctly on Windows
问题截图<img width="1574" height="417" alt="image" src="https://github.com/user-attachments/assets/f676193e-eb0a-4f92-8b50-aad8298f94e5" />

linwu added 2 commits September 8, 2025 19:15
在subprocess.check_call()中添加shell=True参数,解决Windows系统下
执行python.exe ensurepip --upgrade时出现CalledProcessError(returncode 2)的问题

- 添加shell=True参数到subprocess调用
@yzbf-lin
Copy link
Contributor Author

yzbf-lin commented Sep 9, 2025

已修复代码格式问题

@wu-clan
Copy link
Member

wu-clan commented Sep 9, 2025

看起来非常好👍

@wu-clan wu-clan changed the title fix: 修复Windows下subprocess调用失败的问题 Fix the subprocess check call failed in windows Sep 9, 2025
@wu-clan wu-clan merged commit b809497 into fastapi-practices:master Sep 9, 2025
4 checks passed
@wu-clan wu-clan mentioned this pull request Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants