使用django-admin.exe创建Django项目时遇启动器致命错误求助
Hey there, let's work through this issue together. From what you've shared, the core problems are tied to how you set up Django in your virtual environment and some small misconfigurations in your setup steps. Here's a step-by-step fix:
Step 1: Clean up your existing virtual environment
Manual copying of Django files into the virtual environment breaks the isolated dependency management that virtual environments are designed for. Let's start fresh:
- First, exit your active virtual environment:
deactivate - Delete the entire
myvenvdirectory from yourdjangogirls1folder.
Step 2: Recreate the virtual environment and install Django properly
Virtual environments work best when you use pip to handle dependencies, not manual file copies. This ensures all paths and configurations are set up correctly:
- Recreate the virtual environment:
C:\Users\YOUR Name\djangogirls1> python -m venv myvenv - Activate the new virtual environment:
C:\Users\YOUR Name\djangogirls1> myvenv\Scripts\activate - Install Django 2.0.5 directly via
pip(this will automatically handle all dependencies and path references):(myvenv) C:\Users\YOUR Name\djangogirls1> pip install django==2.0.5 - Verify the Django version to confirm a successful install:
You should see(myvenv) C:\Users\YOUR Name\djangogirls1> python -m django --version2.0.5printed in the console.
Step 3: Fix your environment variable configuration
You added an invalid path to your environment variables: C:\Program Files\Python36\Scripts\django-admin.exe\ is a file, not a directory, so it doesn't belong in the PATH.
- Open your system environment variables settings.
- Remove the entry
C:\Program Files\Python36\Scripts\django-admin.exe\. - Keep these valid paths (if they're already present):
C:\Program Files\Python36\C:\Program Files\Python36\Scripts\
Step 4: Create your Django project correctly
I spotted a typo in your original command! You wrote startpoject instead of startproject. Run the corrected command in your activated virtual environment:
(myvenv) C:\Users\YOUR Name\djangogirls1> django-admin startproject mysite .
If you still encounter the launcher error
Sometimes the pip launcher can get corrupted. Fix it by upgrading pip first:
(myvenv) C:\Users\YOUR Name\djangogirls1> python -m pip install --upgrade pip
Then reinstall Django with pip install django==2.0.5 and try creating the project again.
The main issue here was manually copying Django files instead of using pip—virtual environments rely on pip to manage correct paths and dependencies, so manual copies create broken references that trigger the launcher error.
内容的提问来源于stack exchange,提问作者Software Developer

