【问题标题】:starting a django server with cmd使用 cmd 启动 django 服务器
【发布时间】:2020-05-17 10:32:35
【问题描述】:

我为 django 创建了一个虚拟环境并尝试启动服务器,但我一直遇到这个问题

(Django-8VqULu7_) C:\Users\rondo11\Documents\learn how to program\learning python\Django>py 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'

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

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 16, in main
    ) 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?

有什么问题?

【问题讨论】:

  • 最后一行为您提供了可能的解决方案。你确定你在虚拟环境中安装了 Django?
  • 您忘记启动虚拟环境。如果您不知道如何创建虚拟环境,请按照以下步骤操作。

标签: python django cmd command-line


【解决方案1】:

创建虚拟环境

pipenv shell install django在虚拟环境中安装django

pipenv shell 运行虚拟环境

python manage.py runserver启动服务器

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2018-04-15
    • 2021-11-29
    相关资源
    最近更新 更多