I am a complete beginner to Python/Django, but I want to dive right in and start experimenting. Thus I was following this guide on installing Python/Django http://devcenter.
The following guide in official site https://code.djangoproject.com/wiki/InstallationPitfalls
First, you should find location of django-admin.py
by
which django-admin.py
Example: in my case
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py
You use sudo ln -s
to relocate django-admin-py
to /usr/local/bin
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py
after that change permission of the django-admin to be executable
sudo chmod +x /usr/local/bin/django-admin.py
Now you can use
django-admin.py startproject mysite
to create your django project
If you want to change django-admin.py
to django-admin
to look like more compact you can use
sudo mv /usr/local/bin/django-admin.py /usr/local/bin/django-admin
Hope this help for you !
To solve this problem, you need:
Find the main folder of Django, and find the django-admin.py
file
Typically, the file is in <YOUR_DJANGO_FOLDER>/bin/django-admin.py
Create a link for this file
ln -s /bin/django-admin.py /usr/local/bin/django-admin
Type django-admin
in your command to check if it works
if you install django by pip
pip list or pip freeze
if there is django then
pip show django
if location is '/Users/xxxxx/Library/Python/2.7/lib/python/site-packages' then
ln -s /Users/xxxxx/Library/Python/2.7/lib/python/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py
I'm running macOS and I'm using pyenv instead of virtualenv. I'm not sure if they behave similarly, but I was having the same problem in which django-admin.py was not found.
After a while I've noticed that I had a warning after installing django:
pyenv: cannot rehash: /Users/msvolenski/.pyenv/shims/.pyenv-shim exists
Once I deleted this file and ran pyenv rehash
it all started working perfectly.
Hope this helps!
When that didn't work for me, I tried python -m django startproject mysite
and it worked.
Actually, if you use Ubuntu, it's just django-admin
not django-admin.py
.
Resides in /usr/bin
Probably the same thing on Mac.
You're using a Windows tutorial.
It may also tell you
python manage.py runserver
and that is actually
python ./manage.py runserver