简体   繁体   English

ModuleNotFoundError: No module named 'matplotlib' - Deploying Issue of Jupyter Project on Heroku

[英]ModuleNotFoundError: No module named 'matplotlib' - Deploying Issue of Jupyter Project on Heroku

I want to achieve a deployment of a jupyter notebook project on heroku.我想在 heroku 上实现一个 jupyter notebook 项目的部署。 It is basically an interactive notebook what I want to deploy.它基本上是我想要部署的交互式笔记本。 However, during deployment, I face two errors when I trace the log file.但是,在部署过程中,我在跟踪日志文件时遇到了两个错误。

First one is ModuleNotFoundError: No module named 'matplotlib'.第一个是 ModuleNotFoundError:没有名为“matplotlib”的模块。
Second one is "IPython is needed to transform IPython syntax to pure Python. Install ipython if you need this functionality."第二个是“需要 IPython 将 IPython 语法转换为纯 Python。如果需要此功能,请安装 ipython。”

I have both ipython and matplotlib in my system.我的系统中有 ipython 和 matplotlib 。 I checked the versions of both via pip freeze .我通过pip freeze检查了两者的版本。
ipython==7.12.0 ipython==7.12.0
matplotlib==3.1.3 matplotlib==3.1.3

I do not understand why I get those errors.我不明白为什么会出现这些错误。 Any help is highly appreciated!非常感谢任何帮助!

Here is the full log file from Heroku.这是来自 Heroku 的完整日志文件。

(base) MacBook-Pro:minimal-heroku-demo earik$ heroku logs --tail
2020-08-06T18:44:46.883080+00:00 app[web.1]: 
2020-08-06T18:44:46.901384+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data" host=visud.herokuapp.com request_id=ca273d7c-546b-4f7e-b7c2-87816e7ac86e fwd="31.151.169.49" dyno=web.1 connect=0ms service=40ms status=200 bytes=27101 protocol=https
2020-08-06T18:44:47.667700+00:00 app[web.1]: 2020-08-06 18:44:47,667 WebSocket connection opened
2020-08-06T18:44:47.668508+00:00 app[web.1]: 2020-08-06 18:44:47,668 ServerConnection created
2020-08-06T18:45:24.533104+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data/ws" host=visud.herokuapp.com request_id=c13c0bf8-5db0-4616-b07c-b98fcf919bb4 fwd="31.151.169.49" dyno=web.1 connect=1ms service=36872ms status=101 bytes=477 protocol=https
2020-08-06T18:45:24.533488+00:00 app[web.1]: 2020-08-06 18:45:24,533 WebSocket connection closed: code=1001, reason=None
2020-08-06T18:48:37.151660+00:00 heroku[router]: at=info method=GET path="/" host=visud.herokuapp.com request_id=4a9d3492-d274-48cc-93c8-da21141013b3 fwd="31.151.169.49" dyno=web.1 connect=0ms service=4ms status=302 bytes=197 protocol=https
2020-08-06T18:48:37.308781+00:00 app[web.1]: 2020-08-06 18:48:37,308 Error running application handler <bokeh.application.handlers.notebook.NotebookHandler object at 0x7f1836ed4710>: No module named 'matplotlib'
2020-08-06T18:48:37.308790+00:00 app[web.1]: File "vis_ultrafast_data.ipynb", line 14, in <module>:
2020-08-06T18:48:37.308792+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. " Traceback (most recent call last):
2020-08-06T18:48:37.308793+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
2020-08-06T18:48:37.308794+00:00 app[web.1]: exec(self._code, module.__dict__)
2020-08-06T18:48:37.308794+00:00 app[web.1]: File "/app/vis_ultrafast_data.ipynb", line 14, in <module>
2020-08-06T18:48:37.308795+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. "
2020-08-06T18:48:37.308795+00:00 app[web.1]: ModuleNotFoundError: No module named 'matplotlib'
2020-08-06T18:48:37.309124+00:00 app[web.1]: 
2020-08-06T18:48:37.326437+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data" host=visud.herokuapp.com request_id=54338a39-dab0-463b-9519-91b53ffd86e1 fwd="31.151.169.49" dyno=web.1 connect=1ms service=26ms status=200 bytes=27101 protocol=https
2020-08-06T18:48:38.160103+00:00 app[web.1]: 2020-08-06 18:48:38,159 WebSocket connection opened
2020-08-06T18:48:38.160675+00:00 app[web.1]: 2020-08-06 18:48:38,160 ServerConnection created
2020-08-06T18:48:48.443288+00:00 app[web.1]: 2020-08-06 18:48:48,443 Error running application handler <bokeh.application.handlers.notebook.NotebookHandler object at 0x7f1836ed4710>: No module named 'matplotlib'
2020-08-06T18:48:48.443304+00:00 app[web.1]: File "vis_ultrafast_data.ipynb", line 14, in <module>:
2020-08-06T18:48:48.443305+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. " Traceback (most recent call last):
2020-08-06T18:48:48.443306+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
2020-08-06T18:48:48.443306+00:00 app[web.1]: exec(self._code, module.__dict__)
2020-08-06T18:48:48.443307+00:00 app[web.1]: File "/app/vis_ultrafast_data.ipynb", line 14, in <module>
2020-08-06T18:48:48.443307+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. "
2020-08-06T18:48:48.443308+00:00 app[web.1]: ModuleNotFoundError: No module named 'matplotlib'
2020-08-06T18:48:48.443314+00:00 app[web.1]: 
2020-08-06T18:48:48.453408+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data" host=visud.herokuapp.com request_id=cda49257-07b5-471b-98ac-21121ead102e fwd="31.151.169.49" dyno=web.1 connect=1ms service=13ms status=200 bytes=27141 protocol=https
2020-08-06T18:48:48.588733+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data/ws" host=visud.herokuapp.com request_id=bcf674eb-4aa4-40f9-bdcc-ee73d956f61b fwd="31.151.169.49" dyno=web.1 connect=1ms service=10430ms status=101 bytes=474 protocol=https
2020-08-06T18:48:48.589089+00:00 app[web.1]: 2020-08-06 18:48:48,588 WebSocket connection closed: code=1001, reason=None
2020-08-06T18:48:48.969487+00:00 app[web.1]: 2020-08-06 18:48:48,969 WebSocket connection opened
2020-08-06T18:48:48.970460+00:00 app[web.1]: 2020-08-06 18:48:48,970 ServerConnection created
2020-08-06T18:49:13.401206+00:00 heroku[web.1]: Restarting
2020-08-06T18:49:13.415818+00:00 heroku[web.1]: State changed from up to starting
2020-08-06T18:49:14.564555+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-08-06T18:49:14.603078+00:00 app[web.1]: Received signal 15, shutting down
2020-08-06T18:49:14.826506+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data/ws" host=visud.herokuapp.com request_id=a36193de-8d01-4cf8-8eb5-f318c50f9fed fwd="31.151.169.49" dyno=web.1 connect=0ms service=25856ms status=101 bytes=226 protocol=https
2020-08-06T18:49:14.889499+00:00 heroku[web.1]: Process exited with status 0
2020-08-06T18:49:23.764286+00:00 heroku[web.1]: Starting process with command `panel serve --address="0.0.0.0" --port=16711 vis_ultrafast_data.ipynb --allow-websocket-origin=visud.herokuapp.com`
2020-08-06T18:49:31.255019+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/nbconvert/filters/strings.py:214: UserWarning: IPython is needed to transform IPython syntax to pure Python. Install ipython if you need this functionality.
2020-08-06T18:49:31.255085+00:00 app[web.1]: "IPython is needed to transform IPython syntax to pure Python."
2020-08-06T18:49:31.263965+00:00 app[web.1]: 2020-08-06 18:49:31,263 Starting Bokeh server version 2.1.1 (running on Tornado 6.0.4)
2020-08-06T18:49:31.266846+00:00 app[web.1]: 2020-08-06 18:49:31,266 User authentication hooks NOT provided (default user enabled)
2020-08-06T18:49:31.277717+00:00 app[web.1]: 2020-08-06 18:49:31,277 Bokeh app running at: http://0.0.0.0:16711/vis_ultrafast_data
2020-08-06T18:49:31.277927+00:00 app[web.1]: 2020-08-06 18:49:31,277 Starting Bokeh server with process id: 4
2020-08-06T18:49:31.525669+00:00 heroku[web.1]: State changed from starting to up
2020-08-06T18:49:32.538309+00:00 heroku[router]: at=info method=GET path="/" host=visud.herokuapp.com request_id=76019c13-478d-4c32-8c4f-3b41eef167bd fwd="31.151.169.49" dyno=web.1 connect=0ms service=9ms status=302 bytes=197 protocol=https
2020-08-06T18:49:32.760141+00:00 app[web.1]: 2020-08-06 18:49:32,759 Error running application handler <bokeh.application.handlers.notebook.NotebookHandler object at 0x7f18c81ef710>: No module named 'matplotlib'
2020-08-06T18:49:32.760167+00:00 app[web.1]: File "vis_ultrafast_data.ipynb", line 14, in <module>:
2020-08-06T18:49:32.760177+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. " Traceback (most recent call last):
2020-08-06T18:49:32.760179+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
2020-08-06T18:49:32.760180+00:00 app[web.1]: exec(self._code, module.__dict__)
2020-08-06T18:49:32.760180+00:00 app[web.1]: File "/app/vis_ultrafast_data.ipynb", line 14, in <module>
2020-08-06T18:49:32.760181+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. "
2020-08-06T18:49:32.760181+00:00 app[web.1]: ModuleNotFoundError: No module named 'matplotlib'
2020-08-06T18:49:32.760182+00:00 app[web.1]: 
2020-08-06T18:49:32.772732+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data" host=visud.herokuapp.com request_id=96b66b3d-19b4-4f25-868c-530a9e831f76 fwd="31.151.169.49" dyno=web.1 connect=0ms service=28ms status=200 bytes=27101 protocol=https
2020-08-06T18:49:36.494658+00:00 app[web.1]: 2020-08-06 18:49:36,494 WebSocket connection opened
2020-08-06T18:49:36.497244+00:00 app[web.1]: 2020-08-06 18:49:36,497 ServerConnection created
2020-08-06T18:49:39.813220+00:00 app[web.1]: 2020-08-06 18:49:39,812 Error running application handler <bokeh.application.handlers.notebook.NotebookHandler object at 0x7f18c81ef710>: No module named 'matplotlib'
2020-08-06T18:49:39.813231+00:00 app[web.1]: File "vis_ultrafast_data.ipynb", line 14, in <module>:
2020-08-06T18:49:39.813232+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. " Traceback (most recent call last):
2020-08-06T18:49:39.813234+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
2020-08-06T18:49:39.813234+00:00 app[web.1]: exec(self._code, module.__dict__)
2020-08-06T18:49:39.813235+00:00 app[web.1]: File "/app/vis_ultrafast_data.ipynb", line 14, in <module>
2020-08-06T18:49:39.813235+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. "
2020-08-06T18:49:39.813236+00:00 app[web.1]: ModuleNotFoundError: No module named 'matplotlib'
2020-08-06T18:49:39.813242+00:00 app[web.1]: 
2020-08-06T18:49:39.824568+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data" host=visud.herokuapp.com request_id=3a133857-df49-4d73-ab6e-db86455744e3 fwd="31.151.169.49" dyno=web.1 connect=1ms service=20ms status=200 bytes=27141 protocol=https
2020-08-06T18:49:39.965345+00:00 app[web.1]: 2020-08-06 18:49:39,965 Error running application handler <bokeh.application.handlers.notebook.NotebookHandler object at 0x7f18c81ef710>: No module named 'matplotlib'
2020-08-06T18:49:39.965347+00:00 app[web.1]: File "vis_ultrafast_data.ipynb", line 14, in <module>:
2020-08-06T18:49:39.965348+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. " Traceback (most recent call last):
2020-08-06T18:49:39.965349+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
2020-08-06T18:49:39.965349+00:00 app[web.1]: exec(self._code, module.__dict__)
2020-08-06T18:49:39.965350+00:00 app[web.1]: File "/app/vis_ultrafast_data.ipynb", line 14, in <module>
2020-08-06T18:49:39.965350+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. "
2020-08-06T18:49:39.965351+00:00 app[web.1]: ModuleNotFoundError: No module named 'matplotlib'
2020-08-06T18:49:39.965399+00:00 app[web.1]: 
2020-08-06T18:49:39.977708+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data" host=visud.herokuapp.com request_id=6da0a6ff-711c-4a9e-a284-53da62c40688 fwd="31.151.169.49" dyno=web.1 connect=0ms service=18ms status=200 bytes=27141 protocol=https
2020-08-06T18:49:40.117937+00:00 app[web.1]: 2020-08-06 18:49:40,117 WebSocket connection closed: code=1001, reason=None
2020-08-06T18:49:40.121077+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data/ws" host=visud.herokuapp.com request_id=0bfd114d-f5d5-46ad-9db2-ea44b153c9d5 fwd="31.151.169.49" dyno=web.1 connect=1ms service=3629ms status=101 bytes=226 protocol=https
2020-08-06T18:49:40.518095+00:00 app[web.1]: 2020-08-06 18:49:40,517 WebSocket connection opened
2020-08-06T18:49:40.518680+00:00 app[web.1]: 2020-08-06 18:49:40,518 ServerConnection created
2020-08-06T18:49:42.474876+00:00 app[web.1]: 2020-08-06 18:49:42,474 Error running application handler <bokeh.application.handlers.notebook.NotebookHandler object at 0x7f18c81ef710>: No module named 'matplotlib'
2020-08-06T18:49:42.474888+00:00 app[web.1]: File "vis_ultrafast_data.ipynb", line 14, in <module>:
2020-08-06T18:49:42.474893+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. " Traceback (most recent call last):
2020-08-06T18:49:42.474894+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
2020-08-06T18:49:42.474895+00:00 app[web.1]: exec(self._code, module.__dict__)
2020-08-06T18:49:42.474895+00:00 app[web.1]: File "/app/vis_ultrafast_data.ipynb", line 14, in <module>
2020-08-06T18:49:42.474895+00:00 app[web.1]: "Lets first import our transient absorption data. In this case, data file is tab delimited. First row is pixel (wavelength) axis (in nanometer), the first column is time axis (in seconds). Following code creates an interactive figure for time-traces. "
2020-08-06T18:49:42.474896+00:00 app[web.1]: ModuleNotFoundError: No module named 'matplotlib'
2020-08-06T18:49:42.474904+00:00 app[web.1]: 
2020-08-06T18:49:42.484567+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data" host=visud.herokuapp.com request_id=b9747cd6-ae2d-4728-a54a-c7ecb3f6042a fwd="31.151.169.49" dyno=web.1 connect=0ms service=13ms status=200 bytes=27141 protocol=https
2020-08-06T18:49:42.609502+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data/ws" host=visud.herokuapp.com request_id=7f8d60e5-3c22-4a70-a89d-95beb601c62c fwd="31.151.169.49" dyno=web.1 connect=1ms service=2094ms status=101 bytes=474 protocol=https
2020-08-06T18:49:42.610839+00:00 app[web.1]: 2020-08-06 18:49:42,610 WebSocket connection closed: code=1001, reason=None
2020-08-06T18:49:43.025325+00:00 app[web.1]: 2020-08-06 18:49:43,025 WebSocket connection opened
2020-08-06T18:49:43.025793+00:00 app[web.1]: 2020-08-06 18:49:43,025 ServerConnection created
2020-08-06T18:50:21.476754+00:00 heroku[router]: at=info method=GET path="/vis_ultrafast_data/ws" host=visud.herokuapp.com request_id=53a4cd81-8168-48c7-9d62-c4080a9c3c53 fwd="31.151.169.49" dyno=web.1 connect=0ms service=38452ms status=101 bytes=477 protocol=https
2020-08-06T18:50:21.483175+00:00 app[web.1]: 2020-08-06 18:50:21,482 WebSocket connection closed: code=1001, reason=None

make sure to include确保包括

matplotlib==3.1.3

in you 'requirements.txt' that you upload to heroku在您上传到 heroku 的“requirements.txt”中

Finally I made it work.最后我让它工作了。 I cleaned up my jupyter notebook code, and noticed that I no longer need to import matplotlib because I never use it.我清理了我的 jupyter notebook 代码,并注意到我不再需要导入matplotlib因为我从不使用它。

Next thing, eventhough I pushed my changes to heroku, it was still complaining about matplotlib.接下来,即使我将更改推送到 heroku,它仍然在抱怨 matplotlib。 I removed the heroku app and created a new one.我删除了 heroku 应用程序并创建了一个新应用程序。 Then pushed the changes to heroku master.然后将更改推送到 heroku 主控。 Voala!哇啦! It worked!有效!

My requirements file has three components;我的需求文件包含三个部分;

panel
hvplot
nbconvert

This github repo also helped me a lot by the way to find my way through.这个 github repo也帮助了我很多。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jupyter ModuleNotFoundError:没有名为 matplotlib 的模块 - jupyter ModuleNotFoundError: No module named matplotlib ModuleNotFoundError:没有名为“ gi”的模块-在Heroku中部署时 - ModuleNotFoundError: No module named 'gi' - While deploying in Heroku ModuleNotFoundError:部署到heroku时没有名为“useracc”的模块 - ModuleNotFoundError: No module named 'useracc' When deploying to heroku Django / Heroku 部署 - ModuleNotFoundError:“没有名为 'django' 的模块” - Django / Heroku Deploying - ModuleNotFoundError: "No module named 'django'" Jupyter Notebook:ModuleNotFoundError:没有名为“matplotlib.pylot”的模块 - Jupyter Notebook: ModuleNotFoundError: No module named 'matplotlib.pylot' 将 Django 部署到 Heroku 时:ModuleNotFoundError: No module named 'env' - When deploying Django to Heroku: ModuleNotFoundError: No module named 'env' 将 Flask 应用程序部署到 Heroku 时出现“ModuleNotFoundError: No module named 'app'” - Getting "ModuleNotFoundError: No module named 'app'" when deploying Flask app to Heroku 将 Django 部署到 Heroku 时:ModuleNotFoundError: No module named &#39;dotenv&#39; - When deploying Django to Heroku: ModuleNotFoundError: No module named 'dotenv' ModuleNotFoundError:“没有命名的模块<mymodule> ",从 Django 部署到 Heroku 时</mymodule> - ModuleNotFoundError: "No module named <mymodule>", when deploying to Heroku from Django ModuleNotFoundError:没有名为“skmultilearn”Jupyter 的模块 - ModuleNotFoundError: No module named 'skmultilearn' Jupyter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM