执行python3.6 -m virtualenv命令报错400,请求协助排查问题
Hey there, I’ve dealt with similar virtualenv quirks before—especially with older Python versions like 3.6. Let’s walk through the likely issues and fixes for your problem:
First, let’s unpack the symptoms
- When running
python3.6 -m virtualenv ga2, the output gets truncated, hinting at an incomplete setup or hidden error. - Running
python3.6 -m virtualenv test_methrows a 400 error, which almost always relates to failed network requests (like trying to fetch dependencies from PyPI).
Step-by-step fixes to try
1. Upgrade virtualenv to a compatible version
Older virtualenv releases for Python 3.6 might use outdated PyPI endpoints or have bugs that cause 400 errors. Run this to update:
pip3.6 install --upgrade virtualenv
Make sure you’re using the pip3.6 associated with your Python 3.6 installation to avoid version mismatches.
2. Get the full, untruncated error log
The truncated output from your first command is hiding critical details. Redirect the full output to a file to see what’s really going on:
python3.6 -m virtualenv ga2 > setup_log.txt 2>&1
Open setup_log.txt—you might find permission errors, corrupted existing files, or dependency download failures that were cut off in your terminal.
3. Clean up existing virtualenv directories
If the ga2 or test_me directories already exist, they might have leftover corrupted files that block setup. Delete them first:
rm -rf /Users/testytester/virtualenvs/ga2 /Users/testytester/virtualenvs/test_me
Then re-run the virtualenv creation command.
4. Fix the 400 error with a reliable PyPI mirror
A 400 Bad Request error usually means virtualenv is hitting a broken PyPI endpoint. Force a fresh download and use a stable mirror to bypass this:
python3.6 -m virtualenv --download --extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple test_me
The --download flag skips cached dependencies, and the mirror ensures your requests don’t fail due to network or endpoint issues.
5. Verify your Python 3.6 installation
If all else fails, your Python 3.6 setup might be corrupted. Check if it runs properly:
python3.6 --version python3.6 -m pip list
If either command throws errors, reinstall Python 3.6 via Homebrew:
brew reinstall python@3.6
内容的提问来源于stack exchange,提问作者b g

