简体   繁体   English

python manage.py运行服务器返回ImportError

[英]python manage.py run server return ImportError

Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: cannot import name execute_manager

I downloaded a django blog project from github and i want to see if work, then i got this, what's it means? 我从github下载了一个django博客项目,我想看看是否有工作,然后我知道了,这是什么意思?

I have checked the manage.py ,here is the code: 我检查了manage.py,这里是代码:

#!/usr/bin/env python
from django.core.management import execute_manager
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_manager(settings)

some kind of difference from defaults. 与默认值有某种差别。 So if do i have not enough authority to import execute_manager which may not exist? 那么,如果我没有足够的权限来导入可能不存在的execute_manager?

what should i do? 我该怎么办?

Sounds like you are using Django 1.6 or newer where execute_manager() was deprecated and removed : 听起来你正在使用Django 1.6或更高版本,其中execute_manager()弃用删除

The functions setup_environ() and execute_manager() will be removed from django.core.management. 函数setup_environ()和execute_manager()将从django.core.management中删除。 This also means that the old (pre-1.4) style of manage.py file will no longer work. 这也意味着旧的(1.4版之前)样式的manage.py文件将不再起作用。

This django blog project you are using is probably not actively maintained and doesn't support 1.6. 您正在使用的这个django博客项目可能没有主动维护,也不支持1.6。

Use execute_from_command_line() instead: 请改用execute_from_command_line()

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

Also see this manage.py template for Django 1.6 from the django sources. 另请参阅django源代码中的Django 1.6的manage.py模板

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM