python manage.py runserver命令在cmd命令框中可以正确执行,但是在pycharm的终端中运行就失败了!

来源:2-2 初始Django项目

weixin_慕斯卡4581650

2019-11-17 20:39

(venv) E:\python\practise\django\django_instuction>python manage.py runserver

Traceback (most recent call last):

  File "manage.py", line 10, in main

    from django.core.management import execute_from_command_line

ModuleNotFoundError: No module named 'django'



在window的cmd中执行就是好的?

E:\python\practise\django\django_instuction>python manage.py runserver

Watching for file changes with StatReloader

Performing system checks...


System check identified no issues (0 silenced).


You have 17 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.

November 17, 2019 - 17:15:00

Django version 2.2.7, using settings 'django_instuction.settings'

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

Quit the server with CTRL-BREAK.


写回答 关注

1回答

  • weixin_慕斯卡4581650
    2019-11-17 20:47:57

    原因就是直接使用Python的安装目录,不要使用venv目录下的python环境变量!

    优雅CODE

    是需要再那个地方配置?我的也是再cmd中执行正常,但是再pycharm中执行也是不行,提示: Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

    2020-03-19 16:20:30

    共 1 条回复 >

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

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

25587 学习 · 248 问题

查看课程

相似问题