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

前端 未结 21 1654
天涯浪人
天涯浪人 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:27

    I got the same error and I fixed it in this manner:

    I had to activate my virtual environment using the following command

    source python2.7/bin/activate
    
    0 讨论(0)
  • 2020-12-02 12:27

    well, I faced the same error today after installing virtualenv and django. For me it was that I had used sudo (sudo pip install django) for installing django, and I was trying to run the manage.py runserver without sudo. I just added sudo and it worked. :)

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

    I am having the same problem while running the command-

    python manage.py startapp < app_name >

    but problem with me is that i was running that command out of virtual environment.So just activate your virtual environment first and run the command again -

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

    You must choose your Project first before running the server , type this workon your_project_name then python manage.py runserver

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

    This also happens if you change the directory structure of your python project (I did this, and then puzzled over the change in behavior). If you do so, you'll need to change a line in your /bin/activate file. So, say your project was at

    /User/me/CodeProjects/coolApp/
    

    and your activate file is at

    /User/me/CodeProjects/coolApp/venv/bin/activate
    

    when you set up your project, then you changed your project to

    /User/me/CodeProjects/v1-coolApp/
    

    or something. You would then need to open

    /User/me/CodeProjects/v1-coolApp/venv/bin/activate
    

    find the line where it says

    VIRTUAL_ENV="/User/me/CodeProjects/coolApp"
    export VIRTUAL_ENV
    

    and change it to

    VIRTUAL_ENV="/User/me/CodeProjects/v1-coolApp"
    

    before reactivating

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

    had the same problem.run command 'python manage.py migrate' as root. works fine with root access (sudo python manage.py migrate )

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