python - Django 中的 Plotly Dash 应用程序在 __init__() 位置参数上抛出 TypeError
问题描述
我一直在按照这里的例子
https://thinkinfi.com/integrate-plotly-dash-in-django/
如果我使用它指定的确切包的包设置虚拟环境,它工作正常。但是我正在尝试遵循此方法并将其实现到现有的 Django 项目中,因此我更愿意使用最新版本的软件包。改用这些版本
- django-plotly-dash==1.5.0
- 破折号==1.18.1
- 破折号引导组件==0.11.1
- 破折号-daq==0.5.0
- dpd-静态支持==0.0.5
- 白噪声==5.2.0
我收到了这个错误
Exception inside application: __init__() takes 1 positional argument but 2 were given
Traceback (most recent call last):
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/channels/staticfiles.py", line 44, in __call__
return await self.application(scope, receive, send)
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/channels/routing.py", line 71, in __call__
return await application(scope, receive, send)
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/channels/sessions.py", line 47, in __call__
return await self.inner(dict(scope, cookies=cookies), receive, send)
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/channels/sessions.py", line 254, in __call__
return await self.inner(wrapper.scope, receive, wrapper.send)
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/channels/auth.py", line 181, in __call__
return await super().__call__(scope, receive, send)
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/channels/middleware.py", line 26, in __call__
return await self.inner(scope, receive, send)
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/channels/routing.py", line 150, in __call__
return await application(
File "/home/jasontam/Personal/GitProjects/dashboard_django/newEnv/lib/python3.8/site-packages/asgiref/compatibility.py", line 33, in new_application
instance = application(scope)
TypeError: __init__() takes 1 positional argument but 2 were given
有谁知道如何解决它?我有一个类似的设置很好(除了我无法让它使用像这里这样的本地 css 文件,并且当我将它预加载到 html teamplate 中时,它与我用于导航和侧边栏的那个冲突,但这是一个不同的问题)我可以比较,我已经通过了 dash_app_code.py 并标记了所有 div 子数组,以防它是差异的地方,但不幸的是不是。
提前致谢。
解决方案
阅读此链接,他们建议一种解决方法... https://github.com/GibbsConsulting/django-plotly-dash/issues/290
基本上:
pip install channels_redis
- 转到设置文件。
- 评论 INSTALLED_APPS 中的“频道”。
- 将“channels_redis”添加到 INSTALLED_APPS。
这对我有用。
太平洋夏令时。我用 2 个不同的环境进行了测试,这个错误在两个环境中都得到了修复。
环境1:
django==4.0
django_plotly_dash==1.6.6
channels==3.0.4
channels_redis==3.3.1
bootstrap4==0.1.0
dpd_static_support==0.0.5
dash==1.20.0
dash_daq==0.5.0
dash_bootstrap_components==0.13.1
pandas==1.3.5
whitenoise==5.3.0
环境 2
django==3.0.5
django_plotly_dash==1.1.4
channels==3.0.4
channels_redis==3.3.1
bootstrap4==0.1.0
dpd_static_support==0.0.5
dash==1.6.1
dash_daq==0.3.1
dash_bootstrap_components==0.7.2
pandas==1.1.5
whitenoise==5.0.1
推荐阅读
- ruby - 生产服务器上的 Sidekiq 运行时出错
- arduino - 如何在 ENERGIA IDE 上更改 UART 配置(停止位、奇偶校验位等)?
- python - 如何在 Spark 中加快文件写入速度?
- excel - 比较两列并在指定值不可用时突出显示
- linear-algebra - Metric 和 Norm 有什么区别?
- sql - 我在 Oracle EBS ERP R12 中创建警报我写了这个语句,我收到错误 app-alr-01408 SQL 错误 ora-00909 无效的参数数量
- ruby-on-rails - 无法激活 concurrent-ruby-ext-1.1.3,因为 concurrent-ruby-1.1.4 与 concurrent-ruby (= 1.1.3) 冲突 (Gem::ConflictError)
- opendaylight - 如何使用 opendaylight 解析 yin 文件
- dart - 如何在带有 tabBar 的屏幕上 disposeError 后修复 setState
- node.js - 多个下载请求。使用 Node.js 从 S3 signedUrl