Command not found: django-admin.py

前端 未结 27 1846
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 02:40

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.

相关标签:
27条回答
  • 2020-12-03 03:33

    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 !

    0 讨论(0)
  • 2020-12-03 03:34

    To solve this problem, you need:

    1. 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

    2. Create a link for this file

      ln -s /bin/django-admin.py /usr/local/bin/django-admin

    3. Type django-admin in your command to check if it works

    0 讨论(0)
  • 2020-12-03 03:34

    if you install django by pip

    • ensure you have installed django:

    pip list or pip freeze

    if there is django then

    • get location of django:

    pip show django

    if location is '/Users/xxxxx/Library/Python/2.7/lib/python/site-packages' then

    • relocate django-admin-py to /usr/local/bin:

    ln -s /Users/xxxxx/Library/Python/2.7/lib/python/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py

    0 讨论(0)
  • 2020-12-03 03:34

    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!

    0 讨论(0)
  • 2020-12-03 03:35

    When that didn't work for me, I tried python -m django startproject mysite and it worked.

    0 讨论(0)
  • 2020-12-03 03:36

    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
    
    0 讨论(0)
提交回复
热议问题