【问题标题】:Can't install Django, runserver error无法安装 Django,运行服务器错误
【发布时间】:2017-12-03 00:42:44
【问题描述】:

所以我一直在尝试设置 Django,就像 thenewboston(又名 Bucky Roberts)在 youtube 上展示的那样。这是链接:https://www.youtube.com/watch?v=CHjXtRrhqxc&index=2&list=PL6gx4Cwl9DGBlmzzFcLgDhKTTfNLfX1IK 但是当我运行服务器时,我会收到类似

的错误
PS C:\Users\Dante\Desktop> django-admin startproject MyProject1
PS C:\Users\Dante\Desktop> cd .\MyProject1
PS C:\Users\Dante\Desktop\MyProject1> ls


    Directory: C:\Users\Dante\Desktop\MyProject1


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2017-06-29     12:17                .idea
d-----       2017-06-29     12:13                MyProject1
-a----       2017-06-29     12:13            830 manage.py


PS C:\Users\Dante\Desktop\MyProject1> 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'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
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?
PS C:\Users\Dante\Desktop\MyProject1> python manage.py migrate
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'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
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 吗?如果没有,请先这样做。假设你已经安装了 pip(一个 Python 包管理器),那么你可以使用这个命令 pip install Dango 来安装 Django。但首先你可以检查 Django 是由pip show Django 还是pip list 安装的。
  • 将代码粘贴为 sn-p 而不是屏幕截图。您是如何创建项目的?你在使用虚拟环境吗?
  • 请将您的图片替换为 text。图片搜不到,大家都看不到……见meta.stackoverflow.com/questions/285551/…

标签: python django


【解决方案1】:

创建虚拟环境(virtualenv venv)。激活该 virtualenv(源 venv/bin/activate)。然后安装django。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-10
    • 2015-12-16
    • 2016-09-18
    • 1970-01-01
    • 2022-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多