在PyCharm终端中执行python manage.py runserver报错:Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django'

来源:2-2 初始Django项目

慕盖茨3205560

2020-04-08 11:38

D:\DjangoProject\django_introduction>python manage.py runserver

Traceback (most recent call last):

  File "manage.py", line 8, in <module>

    from django.core.management import execute_from_command_line

ModuleNotFoundError: No module named 'django'


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "manage.py", line 14, in <module>

    ) from exc

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?


写回答 关注

3回答

  • weixin_慕尼黑5522580
    2020-07-17 14:04:38

    运行了,还是不行,删除了除conda意外的python,避免了冲突问题,也还是不行

  • 黑项圈
    2020-06-29 18:20:20

    'conda' 不是内部或外部命令,也不是可运行的程序

    或批处理文件。

    ?

  • 慕盖茨3205560
    2020-04-08 11:41:43

    原来在DOS环境下需要先执行:  conda activate命令,然后再执行 python manage.py runserver就可以了。

    如下:

    D:\DjangoProject\django_introduction>conda activate


    (base) D:\DjangoProject\django_introduction>python manage.py runserver

    Performing system checks...


    System check identified no issues (0 silenced).


    You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.

    Run 'python manage.py migrate' to apply them.

    April 08, 2020 - 11:39:34

    Django version 2.1, using settings 'django_introduction.settings'

    Starting development server at http://127.0.0.1:8000/

    Quit the server with CTRL-BREAK.


三小时带你入门Django框架 新版上架

Python开发上手Web框架的必备课程,三小时带你入门Django框架。

25629 学习 · 248 问题

查看课程

相似问题