ImportError: Couldn't import Django

前端 未结 22 1961
无人共我
无人共我 2020-12-05 01:59

I\'ve already configured virtualenv in pycharm, when using the python manage.py command, this is error shown:

E:\\video course\\Python\\code\\web_worker\\MxO         


        
22条回答
  •  半阙折子戏
    2020-12-05 02:39

    1. Check that you have installed Django; by executing import django in python. you mustn't see ModuleNotFoundError if everything's ok.

    2. Check that you have installed virtualenv; by executing virtualenv --version. you must see the version number if everything's ok.

    3. Check that you have enabled virtualenv; there's got to be the name of your virtualenv in your command prompt starting line. enable it by source bin/activate. also, remember to deactivate it every time your job is finished with the virtualenv.

    4. Check that your virtualenv includes django. a virtualenv by default has no modules installed. you either have to install django in your virtualenv (even if you have it in your machine already) or use virtualenv --system-site-packages when creating a virtualenv to include system site packages in the virtualenv.

    5. Add django to your path. open python, import django, then run django to see django's path. then add it to your ~/.bashrc (or ~/.zshrc if you're using zsh). more info in here

    6. Install django-admin by running pip install django-admin

提交回复
热议问题