Reputation: 101
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
Reputation: 1
If you are using pip then run the following commands in cmd:
pip uninstall django
(if django was installed else go to step 2)python -m pip install django
(this seemed to fix the problem instead of pip install django
)Now run django-admin commands, it'll run. Worked for me. Open for correction.
Upvotes: 0
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.
$ python -m pip uninstall Django
$ sudo apt install python3-django
That should fix the issue.
Upvotes: 0
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 .
Upvotes: 0
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
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