【问题标题】:There is no module django.core when starting a project启动项目时没有模块django.core
【发布时间】:2019-05-05 15:41:33
【问题描述】:

嗨,我在 python 2.7 上挣扎了超过 12 个小时,我正在使用 python 3.7,所以出于某种原因我决定更改为 2.7,所以我卸载了 3.7 并安装了 2.7 但是激活虚拟环境后无法启动项目这个错误。 我完成了所有程序here,但我无法解决问题。 我后来尝试在虚拟环境之外安装django的奇怪事情似乎工作正常 但我认为这是不恰当的帮助

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\cipher>pip install virtualenv
Collecting virtualenv
Installing collected packages: virtualenv
Successfully installed virtualenv-16.5.0
C:\Users\cipher>virtualenv market
New python executable in C:\Users\cipher\market\Scripts\python.exe
Installing setuptools, pip, wheel...
done.

C:\Users\cipher>cd market

C:\Users\cipher\market> .\Scripts\activate

(market) C:\Users\cipher\market>pip install django==1.5.4
Collecting django==1.5.4
Installing collected packages: django
Successfully installed django-1.5.4

(market) C:\Users\cipher\market>django-admin.py startproject market
Traceback (most recent call last):
  File "C:\Users\cipher\market\Scripts\django-admin.py", line 2, in <module>
    from django.core import management
ImportError: No module named django.core

(market) C:\Users\cipher\market>

【问题讨论】:

标签: python django


【解决方案1】:

即使您收到安装成功的消息,您也应该仔细检查是否确实如此(在从市场启动的 python shell 中,运行import django 以查看是否抛出任何错误)。无论如何,您都可以尝试重新安装它。如果安装没有问题,可能在使用 .py 文件的命令前加上 python 会有所帮助,如 this page 所示。

【讨论】:

    猜你喜欢
    • 2010-09-23
    • 2023-01-20
    • 2014-12-25
    • 1970-01-01
    • 2022-01-08
    • 2014-08-05
    • 2018-02-02
    • 1970-01-01
    • 2020-10-31
    相关资源
    最近更新 更多