Win10系统下创建Python3.7.2虚拟环境报错求助
Let's work through resolving this error you're hitting when running python -m venv venv. The exit code 101 from ensurepip usually links to path issues, missing Python components, or pip installation failures in your Python 3.7.2 setup. Here are actionable fixes to try:
1. Move Your Project to a Path Without Spaces
Your current working directory has spaces in both "STAR WARE" and "Tricks book" — Windows command line often struggles with spaces when executing nested commands like ensurepip during virtual environment creation.
- Create a new folder with no spaces, e.g.,
C:\Users\STARWARE\Documents\Python\TricksBook - Move your project files to this new folder, then re-run the venv creation command:
python -m venv venv
2. Create the Virtual Env Without Pip, Then Install Pip Manually
If moving the folder isn't an option, skip the ensurepip step during creation and add pip manually afterward:
- First, create the virtual environment without pip:
python -m venv --without-pip venv - Activate the virtual environment:
venv\Scripts\activate.bat - Download the
get-pip.pyscript (you can obtain this from the official Python distribution resources), then run it inside the activated environment:python get-pip.py
3. Reinstall Python 3.7.2 with Full Components
It's possible your Python 3.7.2 installation is missing the ensurepip module or core pip components:
- Uninstall Python 3.7.2 from your Windows Control Panel
- Download the official Python 3.7.2 installer again
- Run the installer, and make sure to:
- Check the box "Add Python 3.7 to PATH"
- Select "Customize Installation" and ensure "pip" is checked under Optional Features
- Complete the installation, then try creating the virtual environment again with admin privileges
Why This Happens
The error occurs because the ensurepip subcommand (which venv runs automatically to set up pip) fails to execute properly. Common triggers on Windows 10 with Python 3.7 include:
- Spaces in the project path causing command parsing errors
- Missing or corrupted
ensurepipfiles in your Python installation - Network issues preventing
ensurepipfrom downloading the latest pip packages
内容的提问来源于stack exchange,提问作者Khaled Saleh

