Django - “no module named django.core.management”

前端 未结 21 1652
天涯浪人
天涯浪人 2020-12-02 11:46

I get the following error when trying to run Django from the command line.

File manage.py, line 8, in 
     from django.core.management import          


        
相关标签:
21条回答
  • 2020-12-02 12:16

    I had the same problem and following worked good, you should navigate main folder in your project than type:

    source bin/activate 
    
    0 讨论(0)
  • 2020-12-02 12:19

    In my case, I am using Ubuntu. The problem can be that I don't have the permission to write to that folder as a normal user. You can simply add the sudo before your command and it should work perfectly. In my case sudo python manage.py syncdb.

    0 讨论(0)
  • 2020-12-02 12:20

    This problem occurs when django is not installed on your computer. When django is not installed which means django.core.management module is also is not installed. So it didn't find this module and it gives error.
    For solving this problem we should install django using pip. Open comand line cmd(on windows) and type as

    pip install django
    

    This command will install django in your computer. If you don't have install pip. you should install pip. Here how to install pip on windows

    0 讨论(0)
  • 2020-12-02 12:20

    File and Directory ownership conflict will cause issues here. Make sure the ownership of the directories and files under the project are to the current user. (You can change them using the chown command with the -R option.) Try rerunning the command: this solved the problem for me when running through the "First Django App" sample:

    python manage.py startapp polls
    
    0 讨论(0)
  • 2020-12-02 12:23

    I had the same issue and the reason I was getting this message was because I was doing "manage.py runserver" whereas doing "python manage.py runserver" fixed it.

    0 讨论(0)
  • 2020-12-02 12:24

    Okay so it goes like this:

    You have created a virtual environment and django module belongs to that environment only.Since virtualenv isolates itself from everything else,hence you are seeing this.

    go through this for further assistance:

    http://www.swegler.com/becky/blog/2011/08/27/python-django-mysql-on-windows-7-part-i-getting-started/

    1.You can switch to the directory where your virtual environment is stored and then run the django module.

    2.Alternatively you can install django globally to your python->site-packages by either running pip or easy_install

    Command using pip: pip install django

    then do this:

    import django print (django.get_version()) (depending on which version of python you use.This for python 3+ series)

    and then you can run this: python manage.py runserver and check on your web browser by typing :localhost:8000 and you should see django powered page.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题