在 django 中导入设置时出现奇怪的错误
我有很多项目在 ubuntu 中使用 python2.7 和 virtualenv/virtualenvwrapper 工作,在我的工作中,一些开发人员使用 macosx 和 windows,通常我像往常一样创建项目:
django-admin.py start project x
我们使用 svn 进行 cvs,但在某些时候,没有什么合理的对我来说,当我尝试类似的操作时:
python manage.py runserver
不起作用,但只适合我并且在我的笔记本电脑中,这不会发生在生产服务器或其他开发人员中。
有什么想法吗?
我收到这个错误:
错误:在包含的目录中找不到文件“settings.py” '管理.py'。看来你已经定制了一些东西。你必须跑 django-admin.py,将其传递给您的设置模块。 (如果文件 settings.py 确实存在,它以某种方式导致了 ImportError。)
但显然,设置文件存在并且位于 manage.py 文件的同一文件夹中,并且不仅仅对我有用...
I have many projects working in ubuntu with python2.7 and virtualenv/virtualenvwrapper, in my work some developers works with macosx and windows, generally I create the project as usual:
django-admin.py start project x
And we use svn for cvs, but in some point, without nothing rational for me, when I try something like:
python manage.py runserver
doesn't work, but is just for me and is in my laptop, that doesn't happens in productions servers or another developers.
any ideas?
I got this error:
Error: Can't find the file 'settings.py' in the directory containing
'manage.py'. It appears you've customized things. You'll have to run
django-admin.py, passing it your settings module. (If the file
settings.py does indeed exist, it's causing an ImportError somehow.)
But obviously, the settings file exists and is in the same folder of manage.py file, and doesn't work just for me...
This happens too with django and appengine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
每当发生导入错误时,
manage.py
脚本都会打印该警告,因此如果您的settings.py
code> 模块导入内容并导致导入错误,manage.py
仍会打印该警告。一种诊断方法是(暂时)将
manage.py
从 更改为并
查看运行
$ python manage.py runserver
时打印的堆栈跟踪。The
manage.py
script prints that warning whenever an import error occurs, so if yoursettings.py
module imports stuff and that causes an import error,manage.py
will still print that warning.One way to diagnose would be to (temporarily) change
manage.py
fromto
and see the stack trace that is printed when running
$ python manage.py runserver
.如果您在尝试开始使用 django 和 appengine 时遇到此错误,同时遵循 http:// www.allbuttonspressed.com/projects/djangoappengine
并且您创建了到文件夹的符号链接,创建 djangoappengine 符号链接时的指南是错误的。您需要进入 1 个目录,例如,
不:
将以下文件夹复制到您的项目中(例如,django-testapp):
固定:
将以下文件夹复制到您的项目中(例如,django-testapp):
注意最后一行。
If you are getting this error when trying to get started with django and appengine, whilst following the guide at http://www.allbuttonspressed.com/projects/djangoappengine
and you created symlinks to the folders, the guide is wrong whilst creating the djangoappengine symlink. You need to go 1 directory e.g.
NOT:
Copy the following folders into your project (e.g., django-testapp):
FIXED:
Copy the following folders into your project (e.g., django-testapp):
Notice the last line.
我花了一个小时搜索 django 代码,直到发现这个:
原来我的应用程序深处存在导入错误。当我看到错误后,花了十秒钟才修复。 :/
I hunted all thru the django code for an hour until I came across this:
Turns out there was an import error deep in my app. Once I could see the error, it took ten seconds to fix. :/