ImportError:无法导入名称索引

发布于 2024-10-11 13:24:50 字数 2156 浏览 5 评论 0原文

第一次运行 uwsgi 时出现此错误: ImportError: 无法导入名称索引

当我取消 uwsgi 并再次运行它时,它可以工作,但站点速度变慢并且随机出现 502 错误。使用 django 开发服务器或使用 HAYSTACK_ENABLE_REGISTRATIONS = False 可以正常工作。

知道出了什么问题吗?

完整回溯:

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 36, in delayed_loader
   return getattr(trans, real_name)(*args, **kwargs)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 193, in activate
   _active[currentThread()] = translation(language)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 176, in translation
   default_translation = _fetch(settings.LANGUAGE_CODE)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
   app = import_module(appname)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 43, in import_module
   __import__(name)

 File "/home/user/prject/apps/external/haystack/__init__.py", line 6, in <module>
   from haystack.sites import site

 File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/__init__.py", line 154, in <module>
   handle_registrations()

 File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/__init__.py", line 151, in handle_registrations
   search_sites_conf = importlib.import_module(settings.HAYSTACK_SITECONF)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 43, in import_module
   __import__(name)

 File "/home/user/project/search_sites.py", line 4, in <module>
   haystack.autodiscover()

 File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/__init__.py", line 121, in autodiscover
   importlib.import_module("%s.search_indexes" % app)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 43, in import_module
   __import__(name)

 File "/home/user/project/apps/activity/search_indexes.py", line 1, in <module>
   from haystack import indexes

ImportError: cannot import name indexes

I get this error when I run uwsgi the first time:
ImportError: cannot import name indexes

When I cancel uwsgi and run it again it works but the site slows down and 502 error appears randomly. With django dev server or with HAYSTACK_ENABLE_REGISTRATIONS = False it works fine.

Any idea whats wrong?

Full Traceback:

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 36, in delayed_loader
   return getattr(trans, real_name)(*args, **kwargs)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 193, in activate
   _active[currentThread()] = translation(language)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 176, in translation
   default_translation = _fetch(settings.LANGUAGE_CODE)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
   app = import_module(appname)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 43, in import_module
   __import__(name)

 File "/home/user/prject/apps/external/haystack/__init__.py", line 6, in <module>
   from haystack.sites import site

 File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/__init__.py", line 154, in <module>
   handle_registrations()

 File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/__init__.py", line 151, in handle_registrations
   search_sites_conf = importlib.import_module(settings.HAYSTACK_SITECONF)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 43, in import_module
   __import__(name)

 File "/home/user/project/search_sites.py", line 4, in <module>
   haystack.autodiscover()

 File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/__init__.py", line 121, in autodiscover
   importlib.import_module("%s.search_indexes" % app)

 File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 43, in import_module
   __import__(name)

 File "/home/user/project/apps/activity/search_indexes.py", line 1, in <module>
   from haystack import indexes

ImportError: cannot import name indexes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

尾戒 2024-10-18 13:24:50

文件“/home/user/project/apps/external/haystack/init.py”
文件“/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/init.py”

包:haystack在两个地方,
您想使用已安装的版本还是将其复制到您的应用程序路径?
删除其中之一。

File "/home/user/prject/apps/external/haystack/init.py"
File "/usr/local/lib/python2.6/dist-packages/django_haystack-1.1.0-py2.6.egg/haystack/init.py"

the package: haystack in two place,
do you want to use installed version or copy it to your app path?
remove one of it.

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