No module named django.core.management

来源:4-10 数据表生成以及apps目录建立

苏家小萝卜

2017-07-08

Bobby老师,我在设置好settings.py文件后,在cmd运行,出现错误了,报错如下:C:\Users\Administrator\PycharmProjects\MxOnline>python manage.py runserver 0.0.0.0:8000

Traceback (most recent call last):

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

    from django.core.management import execute_from_command_line

ImportError: No module named django.core.management

我的settings.py文件设置如下:

import os

import sys

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))


但是我进入虚拟环境以后,又可以运行:

C:\Users\Administrator\PycharmProjects\MxOnline>workon


Pass a name to activate one of the following virtualenvs:

==============================================================================

mxonline

testvir2


C:\Users\Administrator\PycharmProjects\MxOnline>workon mxonline

(mxonline) C:\Users\Administrator\PycharmProjects\MxOnline>python manage.py runserver 0.0.0.0:8000

Performing system checks...


System check identified no issues (0 silenced).

July 08, 2017 - 09:48:25

Django version 1.9.8, using settings 'MxOnline.settings'

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

Quit the server with CTRL-BREAK.


写回答

1回答

bobby

2017-07-10

亲 你的django是安装在虚拟环境中的 当然要进入虚拟环境才能运行了

0
4
慕UI3396178
回复
bobby
老师你的视频又有错误了,麻烦修改一下,4-10,你的代码就是在C盘下面运行的,没有去虚拟目录下面
2018-09-24
共4条回复

Python3.6+django+xadmin,打造在线教育平台

【毕设】Python 2.7到3.6 完美适配,Django升级2.0

3677 学习 · 4038 问题

查看课程