Search code examples
djangodevelopment-environmentpython-venv

Why can't my terminal use the command "django-admin"(my system is windows and I have added path to the environment)


My terminal and cmd cannot identify the command "django-admin" in any folders. However, when I use the terminal inside pyCharm, it functions normally. Can someone help me with the problem and explain why it happens? Thanks a lot.

I have added paths to my environment. enter image description here

But it didn't help.


Solution

  • The fact that there is a folder called Scripts inside your project means that you are using a virtual environment on Windows OS. In this case probably created automatically by your IDE (PyCharm).

    You cannot use the command on CommandPrompt/PowerShell because your system cannot find Django. Its installed inside this virtual environment, which is apart from your OS. PyCharm is probably automatically activating this venv when you open your project and thus that is the reason why you can issue commands form inside the IDE.

    Naturally, you manually activate it:

    > cd C:\Users\86177\pythonProject
    > .\Scripts\activate
    (venv) > django-admin
    

    (venv) indicates that the environment is activated. Note that usually Scripts is inside a folder called venv, the commands I've written are based on the paths on your image.