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回答
-
亲 你的django是安装在虚拟环境中的 当然要进入虚拟环境才能运行了
042018-09-24
相似问题