将dash应用程序部署到heroku时出错,Nidaqmx.lib.DataNotFoundError
Posted
技术标签:
【中文标题】将dash应用程序部署到heroku时出错,Nidaqmx.lib.DataNotFoundError【英文标题】:Error when deployin a dash app to heroku, Nidaqmx.lib.DaqNotFoundError 【发布时间】:2021-09-03 15:32:57 【问题描述】:我正在尝试使用 NI9234 从加速度计远程读取数据。我在 Windows 中工作,我在 python 上使用 plotly dash 和 nidaqmx。整个事情在本地主机上运行良好(能够获取数据并绘制它),但是,当我尝试在 Heroku 上部署它时,我的加速度计根本没有读取任何内容。我认为部署正在运行,但我将其作为我的日志 --tail:
2021-06-19T01:12:23.045293+00:00 heroku[router]: at=info method=GET path="/_dash-component-suites/dash_core_components/async-plotlyjs.v1_16_0m1617903285.js" host=monitoreo-remoto.herokuapp.com request_id=cc5a2471-0689-4b93-91cb-a0d0eb796e82 fwd="187.190.230.255" dyno=web.1 connect=0ms service=325ms status=200 bytes=1034463 protocol=https
2021-06-19T01:12:28.412217+00:00 app[web.1]: Exception on /_dash-update-component [POST]
2021-06-19T01:12:28.412225+00:00 app[web.1]: Traceback (most recent call last):
2021-06-19T01:12:28.412226+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 2070, in wsgi_app
2021-06-19T01:12:28.412227+00:00 app[web.1]: response = self.full_dispatch_request()
2021-06-19T01:12:28.412227+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1515, in full_dispatch_request
2021-06-19T01:12:28.412228+00:00 app[web.1]: rv = self.handle_user_exception(e)
2021-06-19T01:12:28.412228+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1513, in full_dispatch_request
2021-06-19T01:12:28.412228+00:00 app[web.1]: rv = self.dispatch_request()
2021-06-19T01:12:28.412229+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1499, in dispatch_request
2021-06-19T01:12:28.412229+00:00 app[web.1]: return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
2021-06-19T01:12:28.412230+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1079, in dispatch
2021-06-19T01:12:28.412230+00:00 app[web.1]: response.set_data(func(*args, outputs_list=outputs_list))
2021-06-19T01:12:28.412231+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1010, in add_context
2021-06-19T01:12:28.412232+00:00 app[web.1]: output_value = func(*args, **kwargs) # %% callback invoked %%
2021-06-19T01:12:28.412232+00:00 app[web.1]: File "/app/Vib-easy-3.py", line 110, in update_output
2021-06-19T01:12:28.412233+00:00 app[web.1]: with nidaqmx.Task() as task:
2021-06-19T01:12:28.412233+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/task.py", line 84, in __init__
2021-06-19T01:12:28.412233+00:00 app[web.1]: self._handle = lib_importer.task_handle(0)
2021-06-19T01:12:28.412234+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 178, in task_handle
2021-06-19T01:12:28.412234+00:00 app[web.1]: self._parse_typedefs()
2021-06-19T01:12:28.412235+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 241, in _parse_typedefs
2021-06-19T01:12:28.412235+00:00 app[web.1]: version = system.driver_version
2021-06-19T01:12:28.412236+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 73, in driver_version
2021-06-19T01:12:28.412236+00:00 app[web.1]: return DriverVersion(self._major_version, self._minor_version,
2021-06-19T01:12:28.412236+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 108, in _major_version
2021-06-19T01:12:28.412237+00:00 app[web.1]: cfunc = lib_importer.windll.DAQmxGetSysNIDAQMajorVersion
2021-06-19T01:12:28.412237+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 166, in windll
2021-06-19T01:12:28.412238+00:00 app[web.1]: self._import_lib()
2021-06-19T01:12:28.412244+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 218, in _import_lib
2021-06-19T01:12:28.412244+00:00 app[web.1]: raise DaqNotFoundError(
2021-06-19T01:12:28.412252+00:00 app[web.1]: nidaqmx._lib.DaqNotFoundError: Could not find an installation of NI-DAQmx. Please ensure that NI-DAQmx is installed on this machine or contact National Instruments for support.
2021-06-19T01:12:28.418592+00:00 app[web.1]: 10.16.188.22 - - [19/Jun/2021:01:12:28 +0000] "POST /_dash-update-component HTTP/1.1" 500 290 "https://monitoreo-remoto.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/91.0.4472.106 Safari/537.36"
2021-06-19T01:12:28.418956+00:00 heroku[router]: at=info method=POST path="/_dash-update-component" host=monitoreo-remoto.herokuapp.com request_id=fde7d56c-acbe-45f9-a1a6-54293cb22e55 fwd="187.190.230.255" dyno=web.1 connect=0ms service=181ms status=500 bytes=463 protocol=https
2021-06-19T01:12:44.515889+00:00 app[web.1]: Exception on /_dash-update-component [POST]
2021-06-19T01:12:44.515899+00:00 app[web.1]: Traceback (most recent call last):
2021-06-19T01:12:44.515900+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 2070, in wsgi_app
2021-06-19T01:12:44.515901+00:00 app[web.1]: response = self.full_dispatch_request()
2021-06-19T01:12:44.515901+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1515, in full_dispatch_request
2021-06-19T01:12:44.515902+00:00 app[web.1]: rv = self.handle_user_exception(e)
2021-06-19T01:12:44.515902+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1513, in full_dispatch_request
2021-06-19T01:12:44.515903+00:00 app[web.1]: rv = self.dispatch_request()
2021-06-19T01:12:44.515903+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1499, in dispatch_request
2021-06-19T01:12:44.515904+00:00 app[web.1]: return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
2021-06-19T01:12:44.515904+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1079, in dispatch
2021-06-19T01:12:44.515905+00:00 app[web.1]: response.set_data(func(*args, outputs_list=outputs_list))
2021-06-19T01:12:44.515905+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1010, in add_context
2021-06-19T01:12:44.515906+00:00 app[web.1]: output_value = func(*args, **kwargs) # %% callback invoked %%
2021-06-19T01:12:44.515906+00:00 app[web.1]: File "/app/Vib-easy-3.py", line 110, in update_output
2021-06-19T01:12:44.515906+00:00 app[web.1]: with nidaqmx.Task() as task:
2021-06-19T01:12:44.515907+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/task.py", line 84, in __init__
2021-06-19T01:12:44.515907+00:00 app[web.1]: self._handle = lib_importer.task_handle(0)
2021-06-19T01:12:44.515916+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 178, in task_handle
2021-06-19T01:12:44.515917+00:00 app[web.1]: self._parse_typedefs()
2021-06-19T01:12:44.515917+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 241, in _parse_typedefs
2021-06-19T01:12:44.515918+00:00 app[web.1]: version = system.driver_version
2021-06-19T01:12:44.515918+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 73, in driver_version
2021-06-19T01:12:44.515919+00:00 app[web.1]: return DriverVersion(self._major_version, self._minor_version,
2021-06-19T01:12:44.515919+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 108, in _major_version
2021-06-19T01:12:44.515919+00:00 app[web.1]: cfunc = lib_importer.windll.DAQmxGetSysNIDAQMajorVersion
2021-06-19T01:12:44.515920+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 166, in windll
2021-06-19T01:12:44.515920+00:00 app[web.1]: self._import_lib()
2021-06-19T01:12:44.515920+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 218, in _import_lib
2021-06-19T01:12:44.515920+00:00 app[web.1]: raise DaqNotFoundError(
2021-06-19T01:12:44.515921+00:00 app[web.1]: nidaqmx._lib.DaqNotFoundError: Could not find an installation of NI-DAQmx. Please ensure that NI-DAQmx is installed on this machine or contact National Instruments for support.
2021-06-19T01:12:44.530403+00:00 app[web.1]: 10.16.188.22 - - [19/Jun/2021:01:12:44 +0000] "POST /_dash-update-component HTTP/1.1" 500 290 "https://monitoreo-remoto.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36"
2021-06-19T01:12:44.531107+00:00 heroku[router]: at=info method=POST path="/_dash-update-component" host=monitoreo-remoto.herokuapp.com request_id=4cd69bda-50c6-4bd5-8a33-3cd423c725d1 fwd="187.190.230.255" dyno=web.1 connect=1ms service=179ms status=500 bytes=463 protocol=https
2021-06-19T01:12:48.609521+00:00 app[web.1]: Exception on /_dash-update-component [POST]
2021-06-19T01:12:48.609530+00:00 app[web.1]: Traceback (most recent call last):
2021-06-19T01:12:48.609531+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 2070, in wsgi_app
2021-06-19T01:12:48.609531+00:00 app[web.1]: response = self.full_dispatch_request()
2021-06-19T01:12:48.609532+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1515, in full_dispatch_request
2021-06-19T01:12:48.609532+00:00 app[web.1]: rv = self.handle_user_exception(e)
2021-06-19T01:12:48.609533+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1513, in full_dispatch_request
2021-06-19T01:12:48.609533+00:00 app[web.1]: rv = self.dispatch_request()
2021-06-19T01:12:48.609534+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1499, in dispatch_request
2021-06-19T01:12:48.609534+00:00 app[web.1]: return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
2021-06-19T01:12:48.609534+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1079, in dispatch
2021-06-19T01:12:48.609535+00:00 app[web.1]: response.set_data(func(*args, outputs_list=outputs_list))
2021-06-19T01:12:48.609535+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1010, in add_context
2021-06-19T01:12:48.609536+00:00 app[web.1]: output_value = func(*args, **kwargs) # %% callback invoked %%
2021-06-19T01:12:48.609536+00:00 app[web.1]: File "/app/Vib-easy-3.py", line 110, in update_output
2021-06-19T01:12:48.609537+00:00 app[web.1]: with nidaqmx.Task() as task:
2021-06-19T01:12:48.609537+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/task.py", line 84, in __init__
2021-06-19T01:12:48.609537+00:00 app[web.1]: self._handle = lib_importer.task_handle(0)
2021-06-19T01:12:48.609538+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 178, in task_handle
2021-06-19T01:12:48.609538+00:00 app[web.1]: self._parse_typedefs()
2021-06-19T01:12:48.609539+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 241, in _parse_typedefs
2021-06-19T01:12:48.609539+00:00 app[web.1]: version = system.driver_version
2021-06-19T01:12:48.609540+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 73, in driver_version
2021-06-19T01:12:48.609540+00:00 app[web.1]: return DriverVersion(self._major_version, self._minor_version,
2021-06-19T01:12:48.609540+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 108, in _major_version
2021-06-19T01:12:48.609541+00:00 app[web.1]: cfunc = lib_importer.windll.DAQmxGetSysNIDAQMajorVersion
2021-06-19T01:12:48.609541+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 166, in windll
2021-06-19T01:12:48.609542+00:00 app[web.1]: self._import_lib()
2021-06-19T01:12:48.609542+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 218, in _import_lib
2021-06-19T01:12:48.609542+00:00 app[web.1]: raise DaqNotFoundError(
2021-06-19T01:12:48.609543+00:00 app[web.1]: nidaqmx._lib.DaqNotFoundError: Could not find an installation of NI-DAQmx. Please ensure that NI-DAQmx is installed on this machine or contact National Instruments for support.
2021-06-19T01:12:48.612660+00:00 app[web.1]: 10.16.188.22 - - [19/Jun/2021:01:12:48 +0000] "POST /_dash-update-component HTTP/1.1" 500 290 "https://monitoreo-remoto.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36"
2021-06-19T01:12:48.613854+00:00 heroku[router]: at=info method=POST path="/_dash-update-component" host=monitoreo-remoto.herokuapp.com request_id=5a31bc51-2eef-4370-91bf-e91b144e2b37 fwd="187.190.230.255" dyno=web.1 connect=0ms service=185ms status=500 bytes=463 protocol=https
2021-06-19T01:15:31.312757+00:00 app[web.1]: Exception on /_dash-update-component [POST]
2021-06-19T01:15:31.312766+00:00 app[web.1]: Traceback (most recent call last):
2021-06-19T01:15:31.312770+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 2070, in wsgi_app
2021-06-19T01:15:31.312770+00:00 app[web.1]: response = self.full_dispatch_request()
2021-06-19T01:15:31.312771+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1515, in full_dispatch_request
2021-06-19T01:15:31.312771+00:00 app[web.1]: rv = self.handle_user_exception(e)
2021-06-19T01:15:31.312771+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1513, in full_dispatch_request
2021-06-19T01:15:31.312772+00:00 app[web.1]: rv = self.dispatch_request()
2021-06-19T01:15:31.312772+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/flask/app.py", line 1499, in dispatch_request
2021-06-19T01:15:31.312773+00:00 app[web.1]: return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
2021-06-19T01:15:31.312773+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1079, in dispatch
2021-06-19T01:15:31.312774+00:00 app[web.1]: response.set_data(func(*args, outputs_list=outputs_list))
2021-06-19T01:15:31.312774+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 1010, in add_context
2021-06-19T01:15:31.312775+00:00 app[web.1]: output_value = func(*args, **kwargs) # %% callback invoked %%
2021-06-19T01:15:31.312775+00:00 app[web.1]: File "/app/Vib-easy-3.py", line 110, in update_output
2021-06-19T01:15:31.312776+00:00 app[web.1]: with nidaqmx.Task() as task:
2021-06-19T01:15:31.312776+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/task.py", line 84, in __init__
2021-06-19T01:15:31.312777+00:00 app[web.1]: self._handle = lib_importer.task_handle(0)
2021-06-19T01:15:31.312777+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 178, in task_handle
2021-06-19T01:15:31.312778+00:00 app[web.1]: self._parse_typedefs()
2021-06-19T01:15:31.312778+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 241, in _parse_typedefs
2021-06-19T01:15:31.312779+00:00 app[web.1]: version = system.driver_version
2021-06-19T01:15:31.312779+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 73, in driver_version
2021-06-19T01:15:31.312780+00:00 app[web.1]: return DriverVersion(self._major_version, self._minor_version,
2021-06-19T01:15:31.312780+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/system/system.py", line 108, in _major_version
2021-06-19T01:15:31.312780+00:00 app[web.1]: cfunc = lib_importer.windll.DAQmxGetSysNIDAQMajorVersion
2021-06-19T01:15:31.312781+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 166, in windll
2021-06-19T01:15:31.312781+00:00 app[web.1]: self._import_lib()
2021-06-19T01:15:31.312781+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nidaqmx/_lib.py", line 218, in _import_lib
2021-06-19T01:15:31.312782+00:00 app[web.1]: raise DaqNotFoundError(
2021-06-19T01:15:31.312783+00:00 app[web.1]: nidaqmx._lib.DaqNotFoundError: Could not find an installation of NI-DAQmx. Please ensure that NI-DAQmx is installed on this machine or contact National Instruments for support.
2021-06-19T01:15:31.317641+00:00 app[web.1]: 10.5.190.247 - - [19/Jun/2021:01:15:31 +0000] "POST /_dash-update-component HTTP/1.1" 500 290 "https://monitoreo-remoto.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36"
2021-06-19T01:15:31.315041+00:00 heroku[router]: at=info method=POST path="/_dash-update-component" host=monitoreo-remoto.herokuapp.com request_id=b613139d-c395-4571-923c-1f6c466a1b2d fwd="187.190.230.255" dyno=web.1 connect=1ms service=131ms status=500 bytes=463 protocol=https
我不知道哪个部分很重要,但是下面一行引起了我的注意:
nidaqmx._lib.DaqNotFoundError: Could not find an installation of NI-DAQmx. Please ensure that NI-DAQmx is installed on this machine or contact National Instruments for support.
我正在使用免费的 Heroku 版本,但我不知道这里是否有人遇到过这个问题。
【问题讨论】:
【参考方案1】:在很多天没有答案后,我将发布我认为正在发生的事情,并发布一个不涉及 heroku 的可行解决方案。
我的理论: python 中的 nidaqmx 库需要来自 National Instruments 的download。如果你没有它,那么它就行不通。该安装仅适用于 Windows。我猜 Heroku 的服务器没有这些文件。
在Heroku之后,我尝试在pythonanywhere运行我的程序,甚至使用了Docker;这些方法都不起作用(也许我做错了什么,或者可能是上面的相同问题)
经过多天的阅读、搜索和尝试不同的方法,我找到了一个不错且简单的解决方案; ngrok。
基本上你只需要register,下载压缩包,解压缩并将ngrok.exe粘贴到C:/Windows/system32。将路径添加到您的env variables(检查来自 il0v3d0g 的答案),然后在本地服务器(例如端口 3040)中运行您的 dash 应用程序,最后在另一个 Windows bash cmd 中运行 ngrok 命令
ngrok http 3040
这将在您的本地主机(即运行您的 dash 应用程序)和互联网上任何其他计算机之间创建一个“隧道”,并使用 ngrok 创建的转发地址。
这是我的“设置”的粗略示意图
如果有人想知道仪表板应用程序是什么样的,我也会添加它(以防像我这样的工程师陷入远程数据获取的可怕任务)
#Working program, on dash program folder.
#Working with bootstrap instead of daq.
# Se debe instalar bootstrap: pip install bootstrap-core-components
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objects as go
from dash.exceptions import PreventUpdate
import nidaqmx
from nidaqmx.constants import AcquisitionType
import numpy as np
app = dash.Dash(__name__)
#Initial conditions to have something in the graph
trace_1 = go.Scatter(
x = [],
y = []
)
layout = go.Layout(title = 'Título de gráfica')
fig = go.Figure(data = [trace_1], layout = layout)
app.layout = dbc.Container(
[
# Toma todo el espacio de arriba para el título.
dbc.Row(
dbc.Col(html.H3('Monitoreo Remoto V-0.3', className = 'text-center text-primary mb-4'), width = 12)
),
# Esto es otra fila que va a tener dos dropdowns y el botón en la misma columna
dbc.Row(
[
dbc.Col(
[
dbc.Button(
'Capturar',
color = 'primary',
id = 'Swtc_1',
n_clicks = 0
),
dcc.Dropdown(
id = 'f_muestreo',
value = '2048',
multi = False,
disabled = False,
persistence = 'string',
persistence_type = 'session',
options = [
'label' : '2048', 'value':'2048',
'label' : '2560', 'value':'2560',
'label' : '3200', 'value':'3200',
'label' : '5120', 'value':'5120',
'label' : '6400', 'value':'6400',
'label' : '10240', 'value':'10240',
'label' : '12800', 'value':'12800',
'label' : '25600', 'value':'25600'
],
),
dcc.Dropdown(
id = 'muestras',
value = '2048',
multi = False,
disabled = False,
persistence = 'string',
persistence_type = 'session',
options = [
'label' : '2048', 'value':'2048',
'label' : '4096', 'value':'4096',
'label' : '8192', 'value':'8192',
'label' : '16384', 'value':'16384',
'label' : '32768', 'value':'32768',
'label' : '65536', 'value':'65536',
'label' : '131072', 'value':'131072'
],
),
], width = 2
),
# Dentro de la misma fila, se va a meter una nueva columna; para la gráfica.
dbc.Col(
dcc.Graph(id = 'plot_id', figure = fig), width = 9
)
],
)
]
)
# interaction
@app.callback(
Output('plot_id', 'figure'),
[Input('Swtc_1', 'n_clicks'),
Input('f_muestreo', 'value'),
Input('muestras', 'value')]
)
def update_output(n_clicks, value_1, value_2):
changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
if 'n_clicks' in changed_id:
sample_rate = int(value_1)
samples_to_acq = int(value_2)
wait_time = samples_to_acq/sample_rate
# Name and channel of my NI 9234
channel_name = 'cDAQBAYO1Mod1/ai0'
# Not using the trig yet
# trig_name = 'cDAQBAYO1Mod1/ai1'
cont_mode = AcquisitionType.CONTINUOUS
units_g = nidaqmx.constants.AccelUnits.G
with nidaqmx.Task() as task:
# Create accelerometer channel and configure sample clock and trigger specs
task.ai_channels.add_ai_accel_chan(channel_name, units = units_g)
task.timing.cfg_samp_clk_timing(sample_rate, sample_mode = cont_mode, samps_per_chan=samples_to_acq)
# Esto es para el tacómetro, de momento está omitido
# task.triggers.start_trigger.cfg_dig_edge_start_trig(trigger_source = trig_name)
# Reading data from sensor and generating time data with numpy
ydata = task.read(number_of_samples_per_channel=samples_to_acq)
xdata = np.linspace(0, wait_time,samples_to_acq)
trace_1 = go.Scatter(
x = list(xdata),
y = list(ydata)
)
layout = go.Layout(title = 'Oscilograma')
fig = go.Figure(data = [trace_1], layout = layout)
n_clicks = 0
return (fig)
else:
raise PreventUpdate
if __name__ == '__main__':
app.run_server(debug = False, port = 3040)
【讨论】:
以上是关于将dash应用程序部署到heroku时出错,Nidaqmx.lib.DataNotFoundError的主要内容,如果未能解决你的问题,请参考以下文章
将 parse-dashboard 部署到 heroku 时出错
将 Cookiecutter-Django 应用程序部署到 Heroku 时出错
使用 Tomcat 和 Mysql 将应用程序部署到 Heroku 时出错