蟒蛇 + Django ImportError:无法将名称信号从Python2.5导入到Python2.7
我已经安装了 django 注册。我刚刚将我的 Python 安装从 2.5 更新到 2.7。
一切正常,但当我尝试运行 Django 应用程序时,出现以下错误。
C:\django\pley>python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x02FA6830>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 48, in inner_run
self.validate(display_num_errors=True)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 249,
in validate
num_errors = get_validation_errors(s, app)
File "C:\Python27\lib\site-packages\django\core\management\validation.py", lin
e 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 146, in
get_app_errors
self._populate()
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 64, in
_populate
self.load_app(app_name)
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 78, in
load_app
models = import_module('.models', app_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "C:\django\pley\..\pley\accounts\models.py", line 3, in <module>
from registration import signals
ImportError: cannot import name signals
如果您需要更多详细信息,例如其他文件的代码,请对此问题发表评论,以便我可以更新。
I have django-registration installed. I just updated my Python installation from 2.5 to 2.7.
Everything works okay but when I try to run my Django app, I get the error below.
C:\django\pley>python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x02FA6830>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 48, in inner_run
self.validate(display_num_errors=True)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 249,
in validate
num_errors = get_validation_errors(s, app)
File "C:\Python27\lib\site-packages\django\core\management\validation.py", lin
e 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 146, in
get_app_errors
self._populate()
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 64, in
_populate
self.load_app(app_name)
File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 78, in
load_app
models = import_module('.models', app_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "C:\django\pley\..\pley\accounts\models.py", line 3, in <module>
from registration import signals
ImportError: cannot import name signals
If you need more details, like the code for the other files, just comment on this question so that I can update.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说似乎没问题。当你解压 django-registration 时,你会得到 2 个文件夹
doc
和 <代码>注册。在registration
文件夹中,您有一个名为signals.py
的文件。这正是您的 django 应用程序尝试导入的文件。查看您是否已将 django-registration 添加为项目 settings.py 中的 INSTALLED_APPS。
Seems ok to me. When you unpack django-registration you get 2 folders
doc
andregistration
. Inregistration
folder you have a file calledsignals.py
. This is precisely the file that your django app is trying to import.Either see if you have added
django-registration
as INSTALLED_APPS in your project settings.py.好吧,我自己来回答这个问题。感谢 #django freenode 的巴哈马。
首先进入你的Python shell
执行以下操作:
我在目录中没有找到
signals.py
。因此,从以下位置下载 tar.gz 文件: https://bitbucket.org/ubernostrum/django-registration /src 并重新安装。
TL;DR
我的 django-registration 安装有问题(没有 signal.py)。从源下载并手动重新安装。
Okay, I'm going to answer this myself. Thanks to bahamas from #django freenode.
First go to your Python shell
Do a:
I did not find
signals.py
in the directory.So, download the tar.gz file from: https://bitbucket.org/ubernostrum/django-registration/src and reinstall.
TL;DR
I had a broken a installation (no signals.py) of django-registration. Download from source and reinstall manually.