Cannot Start Django Project with "django-admin startproject project"

I tried to run the command

django-admin startproject app

but it gave me the following error-

'django-admin' is not recognized as an internal or external command,
operable program or batch file.

. I executed

pip3 uninstall Django

and the result was

Found existing installation: Django 3.1.1
Uninstalling Django-3.1.1:
  Would remove:
    c:\users\radma\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\scripts\django-admin.exe
    c:\users\radma\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\scripts\django-admin.py
    c:\users\radma\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages\django-3.1.1.dist-info\*
    c:\users\radma\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages\django\*
Proceed (y/n)?

I use Windows 10 and Django used to work fine but I had to reset Windows so all my data in C drive was erased and when I tried to use Django today, this happened.

I reinstalled Django and got these warnings-

  WARNING: The script django-admin.exe is installed in 'C:\Users\radma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available.
You should consider upgrading via the 'C:\Users\radma\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

. The second one seems to be easy to fix but I do not know how to fix the first one. Could someone please help me?

Rather than trying to install / manage your Django installation globally, I would recommend you create your development environment(s) using a Python virtual environment.

See the following for further information:

Thank you but I am not interested in that actually.

That’s your call, but it is contrary to the documented best practices for running Django in a Windows environment.

1 Like

I set up my virtual environment but it did not work. :frowning:

Bump

It seems that your python installation is broken, which makes sense, when your system drive was reset. Entirely uninstall python. Reinstall it properly. During the installation it will prompt you to add stuff to you PATH variable. Do that and when you’re done, try setting up a virtual environment properly. Once that has worked, install django into that virtual environment.
When your virtual environment is active, make sure you only use “pip” and not “pip3” or any other versions. The venv overwrites “pip” and “python”, but not the rest.

1 Like

Thank you very much! That worked! :smiley: