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

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

    In case this is helpful to others... I had this issue because my virtualenv defaulted to python2.7 and I was calling Django using Python3 while using Ubuntu.

    to check which python my virtualenv was using:

    $ which python3
    >> /usr/bin/python3
    

    created new virtualenv with python3 specified (using virtualenv wrapper https://virtualenvwrapper.readthedocs.org/en/latest/):

    $ mkvirtualenv --python=/usr/bin/python3 ENV_NAME
    

    the python path should now point to the virtualenv python:

    $ which python3
    >> /home/user/.virtualenvs/ENV_NAME/bin/python3
    

提交回复
热议问题