python运行项目报错,有没有大神解答一下呀~~~~
报错如下:Traceback(mostrecentcalllast):File"manage.py",line14,inexecute_from_command_line...
报错如下:
Traceback (most recent call last):
File "manage.py", line 14, inexecute_from_command_line(settings)
File "C:\Python27\lib\site-packages\django-1.11-py2.7.egg\django\core\
nt\__init__.py", line 362, in execute_from_command_line
utility = ManagementUtility(argv)
File "C:\Python27\lib\site-packages\django-1.11-py2.7.egg\django\core\
nt\__init__.py", line 139, in __init__
self.prog_name = os.path.basename(self.argv[0])
TypeError: 'module' object has no attribute '__getitem__'
我的setting文件是这么写的:
#!/usr/bin/env python
from django.core.management import execute_from_command_line
import imp
try:
imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)
import settings
if __name__ == "__main__":
execute_from_command_line(settings) 展开
Traceback (most recent call last):
File "manage.py", line 14, inexecute_from_command_line(settings)
File "C:\Python27\lib\site-packages\django-1.11-py2.7.egg\django\core\
nt\__init__.py", line 362, in execute_from_command_line
utility = ManagementUtility(argv)
File "C:\Python27\lib\site-packages\django-1.11-py2.7.egg\django\core\
nt\__init__.py", line 139, in __init__
self.prog_name = os.path.basename(self.argv[0])
TypeError: 'module' object has no attribute '__getitem__'
我的setting文件是这么写的:
#!/usr/bin/env python
from django.core.management import execute_from_command_line
import imp
try:
imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)
import settings
if __name__ == "__main__":
execute_from_command_line(settings) 展开
展开全部
应该是settings路径问题,可以参考这篇文章http://blog.csdn.net/echoyjj/article/details/17309373
来自:求助得到的回答
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询