蟒蛇 + Django ImportError:无法将名称信号从Python2.5导入到Python2.7

发布于 2024-09-26 09:10:27 字数 1455 浏览 1 评论 0原文

我已经安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

可是我不能没有你 2024-10-03 09:10:27

对我来说似乎没问题。当你解压 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 and registration. In registration folder you have a file called signals.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.

生生漫 2024-10-03 09:10:27

好吧,我自己来回答这个问题。感谢 #django freenode 的巴哈马。

首先进入你的Python shell

>>> import registration
>>> print registration.__file__
/home/wenbert/.local/lib/python/registration/__init__.pyc

执行以下操作:

$ ls -la /home/wenbert/.local/lib/python/registration

我在目录中没有找到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

>>> import registration
>>> print registration.__file__
/home/wenbert/.local/lib/python/registration/__init__.pyc

Do a:

$ ls -la /home/wenbert/.local/lib/python/registration

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文