连接 django-rq 时出错:ImportError: cannot import name get_failed_queue
Posted
技术标签:
【中文标题】连接 django-rq 时出错:ImportError: cannot import name get_failed_queue【英文标题】:Error connecting django-rq: ImportError: cannot import name get_failed_queue 【发布时间】:2019-10-24 04:20:06 【问题描述】:从未与django-rq
、redis
合作过。我想这个问题应该很容易解决,但我不知道如何解决。
当我启动服务器时,我收到此错误ImportError: cannot import name get_failed_queue
我正在使用 Python 2.7
完整的追溯
Unhandled exception in thread started by <function wrapper at 0x7f8d45706410>
Traceback (most recent call last):
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/m0nte-cr1st0/work_projects/startapp/finbee/finbee/urls.py", line 27, in <module>
url(r'^admin/rq/', include('django_rq_dashboard.urls')),
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django_rq_dashboard/urls.py", line 3, in <module>
from . import views
File "/home/m0nte-cr1st0/.virtualenvs/finbee/local/lib/python2.7/site-packages/django_rq_dashboard/views.py", line 16, in <module>
from rq import Queue, Worker, get_failed_queue, push_connection
ImportError: cannot import name get_failed_queue
包装清单
aenum 2.1.2
appdirs 1.4.3
asn1crypto 0.24.0
bcrypt 3.1.6
cached-property 1.5.1
certifi 2019.3.9
cffi 1.12.3
chardet 3.0.4
Click 7.0
croniter 0.3.30
cryptography 2.7
dbf 0.96.8
defusedxml 0.6.0
Django 1.9.13
django-admin-extensions 0.10.0
django-appconf 1.0.3
django-autocomplete-light 3.3.5
django-debug-toolbar 1.4
django-filebrowser-no-grappelli 3.7.8
django-flat-theme 1.1.4
django-imagekit 4.0.2
django-nested-inline 0.3.7
django-pipeline 1.6.12
django-rq 2.0 /home/m0nte-cr1st0/.virtualenvs/finbee/src/django-rq
django-rq-dashboard 0.3.0
django-selectable 0.9.0
django-static-sitemaps 4.2.1
django-tinymce 2.8.0
django-treebeard 4.3
django-uuslug 1.1.8
django-widget-tweaks 1.4.1
djlime 0.0.36 /home/m0nte-cr1st0/.virtualenvs/finbee/src/djlime/src
EasyProcess 0.2.7
enum34 1.1.6
Fabric 1.10.2
factory-boy 2.5.2
fake-useragent 0.1.5
html5lib 1.0.1
idna 2.8
ipaddress 1.0.22
isodate 0.6.0
lxml 3.7.1
paramiko 2.4.2
patool 1.12
pilkit 2.0
Pillow 6.0.0
pip 19.1.1
pkg-resources 0.0.0
psycopg2 2.8.2
pyasn1 0.4.5
pycparser 2.19
PyNaCl 1.3.0
python-dateutil 2.8.0
python-slugify 3.0.2
pytz 2019.1
pyunpack 0.1.2
redis 3.2.1
requests 2.22.0
requests-toolbelt 0.9.1
rq 1.0
rq-scheduler 0.6.0
setuptools 41.0.1
simplejson 3.16.0
six 1.12.0
sqlparse 0.3.0
text-unidecode 1.2
urllib3 1.25.3
webencodings 0.5.1
wheel 0.33.4
zeep 1.1.0
感谢关注
【问题讨论】:
【参考方案1】:发生这种情况是因为您使用需要rq>=1.0
的django-rq==2.0
。 get_failed_queue()
函数在 rq==1.0 中不再存在,请阅读发行说明以了解如何更改代码以使其再次工作:https://github.com/rq/rq/releases/tag/v1.0
否则,您可以降级到 django-rq==1.3.1 和 rq==0.13
【讨论】:
以上是关于连接 django-rq 时出错:ImportError: cannot import name get_failed_queue的主要内容,如果未能解决你的问题,请参考以下文章