raa95
raa95

Reputation: 101

Installed Django but django-admin is not found

I just installed django using pip but when I try to create a new project using django-admin I get "bash: django-admin: command not found". I tried installing django in a virtualenv but I'm still getting the same error when trying to create a new project.

While I was trying to solve this issue I found this: Installing Django with pip, django-admin not found

The last answer is saying that django-admin may not be on the path. Can anyone explain me please what does this mean?

If I run "find / -name django-admin.py" I get this:

/home/user/.local/bin/django-admin.py
/home/user/.local/lib/python3.5/site-packages/django/bin/django-admin.py
/home/user/django-admin.py

Can anyone give me some help please? Thank you.

Upvotes: 10

Views: 18037

Answers (5)

Sk Jameel Akhtar
Sk Jameel Akhtar

Reputation: 1

If you are using pip then run the following commands in cmd:

  1. pip uninstall django (if django was installed else go to step 2)
  2. python -m pip install django (this seemed to fix the problem instead of pip install django )
  3. Find the Python folder in your installation drive and then >> Scripts Copy the path and add them to Environment Variables

Now run django-admin commands, it'll run. Worked for me. Open for correction.

Upvotes: 0

ChrisM
ChrisM

Reputation: 42

Just in case someone is experiencing this issue, you can just install django using apt package manager instead of pip. I am not sure if this is the best way to do it but it worked for me.

  1. First you need to uninstall the current installation of django. In this case you can run $ python -m pip uninstall Django
  2. Then run $ sudo apt install python3-django

That should fix the issue.

Upvotes: 0

yveszenne
yveszenne

Reputation: 736

I also experienced this error but none of the above works for me. This is how I got this silly mistake of me. Example,

$ mkdir django_test cd django_test
$ pipenv shell
(django_test)$ django-admin startproject django_test .
zsh:command not found: django-admin

To solve this error: Don't forget to install your django version in your virtual environment first if you are using.

$ mkdir django_test cd django_test
$ pipenv shell
(django_test)$ pipenv install django==3.0.5 # change the version you are using
(django_test)$ django-admin startproject .

Terminal commands

Upvotes: 0

Naelson Douglas
Naelson Douglas

Reputation: 61

I had the same problem. My "solution" was to call django-admin directly like

/usr/local/bin/django-admin startproject MyProject

Upvotes: 2

Rizwan Saeed
Rizwan Saeed

Reputation: 451

You have installed Django using your account instead of sudo

so do the following to resolve this

$ pip3 uninstall django

$ sudo pip3 install django

This is the output

$which django-admin
/usr/local/bin/django-admin

Upvotes: 45

Related Questions