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

Windows10下执行django-admin startproject报错:Command not found: django-admin.py求助

Fixing "Command not found: django-admin.py" on Windows 10 with Virtual Environments

Hey there! Let's sort out that django-admin command error you're facing—since you're new to Django and virtual environments on Windows, this is a really common hiccup, so no need to stress. Here are step-by-step fixes to get you up and running:

1. Ensure your virtual environment is activated

First off, you need to make sure you're working inside your activated virtual environment. On Windows, navigate to your project folder in Command Prompt and run:

.\venv\Scripts\activate

You'll know it's active when you see (venv) at the start of your command prompt. If you skip this step, your system is trying to use a global Django installation (which likely doesn't exist) instead of the one you installed in your virtual env.

2. Use python -m django as a reliable alternative

Sometimes the django-admin script doesn't get added to your PATH correctly even in the activated venv. A foolproof workaround is to call Django directly via Python's module system:

python -m django startproject xxxxxx

This will use the Django installation from your active virtual environment every time, so it should work as long as Django is installed there.

3. Confirm Django is installed in your virtual environment

With your venv activated, run this command to check if Django is properly installed:

pip list

Look for "Django" in the output. If it's missing, reinstall it (make sure the venv is still active!) with:

pip install django

4. Check if your venv's Scripts folder is in PATH (optional)

If you want to use django-admin directly without the python -m prefix, verify that your virtual environment's Scripts folder is in your PATH. Activating the venv should add this automatically, but glitches can happen. Run this to check:

echo %PATH%

Look for a path like C:\your-project-directory\venv\Scripts in the output. If it's missing, add it temporarily with:

set PATH=%PATH%;C:\your-project-directory\venv\Scripts

Now try running django-admin startproject xxxxxx again—it should work.

Once you get your project created, remember to keep your virtual environment activated whenever you work on your Django project. This keeps your dependencies isolated and prevents similar issues later on!

内容的提问来源于stack exchange,提问作者debajyoti panda

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 15:52:36