{"id":551,"date":"2021-03-08T03:57:13","date_gmt":"2021-03-08T03:57:13","guid":{"rendered":"http:\/\/paynecentral.com\/tompayne\/?p=551"},"modified":"2021-03-08T14:52:58","modified_gmt":"2021-03-08T14:52:58","slug":"python-dash-plotly","status":"publish","type":"post","link":"https:\/\/paynecentral.com\/tompayne\/2021\/03\/08\/python-dash-plotly\/","title":{"rendered":"Python, Dash &#038; Plotly"},"content":{"rendered":"\n<p>After playing with a number of monitoring tools to keep track of the various sites and devices around the house, since none of them did what I envisioned, I decided to try to take a stab at building my own app. I thought about doing it as a mobile app, but realized a web app would be much more versatile. After some searching, I came across Plotly and think it might suite my needs.<\/p>\n\n\n\n<p><a href=\"https:\/\/plotly.com\/solutions\/manufacturing\/\">This<\/a> Dash example got me particularly excited: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/dash-gallery.plotly.host\/dash-manufacture-spc-dashboard\/\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"467\" src=\"https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1024x467.png\" alt=\"\" class=\"wp-image-552\" srcset=\"https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1024x467.png 1024w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-300x137.png 300w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-768x350.png 768w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1536x700.png 1536w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-2048x933.png 2048w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1200x547.png 1200w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1980x902.png 1980w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>(Initially found <a href=\"https:\/\/dash-gallery.plotly.host\/Portal\/\">here<\/a>)<\/p>\n\n\n\n<p>I got to work installing Python, Plotly and Dash on a spare Raspberry Pi Zero W I had been using for monitor experiments with Zabbix and Nagios.<\/p>\n\n\n\n<p>I immediately started running into some issues. The code I was trying to run was very basic from Plotly\/Dash <a href=\"https:\/\/dash.plotly.com\/layout\">examples<\/a>. It would run, and said it was rendering on port 127.0.01:8050 but when I would try to connect remotely (say to 192.168.1.174:8050), the connection would be refused.<\/p>\n\n\n\n<p>Since was running the RPi headless, I couldn&#8217;t connect to 127.0.01, so I tried to get the code to run on my MacBook. Now I was getting errors running the same code. After some research, I found our that calling my program &#8220;test.py&#8221; conflicted with the dash library. Simply renaming the code to test2.py allowed it to work.<\/p>\n\n\n\n<p>It was now rendering on 127.0.0.1:8050, but refusing to connect on the MacBook&#8217;s lan address<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/61678129\/how-to-access-a-plotly-dash-app-server-via-lan\">This<\/a> is where I learned I need to include <code>host = '0.0.0.0'<\/code>in the &#8220;run server()&#8221; function in order for the integrated web server to listed on any host. I modified the code on my RPi and now am very happily seeing:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"598\" src=\"https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1-1024x598.png\" alt=\"\" class=\"wp-image-553\" srcset=\"https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1-1024x598.png 1024w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1-300x175.png 300w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1-768x449.png 768w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1-1536x897.png 1536w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1-1200x701.png 1200w, https:\/\/paynecentral.com\/tompayne\/wp-content\/uploads\/sites\/2\/2021\/03\/image-1.png 1774w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>8 March 2021:<\/p>\n\n\n\n<p>I am using a YouTube <a href=\"https:\/\/www.youtube.com\/watch?v=iAXwlrtBUEY&amp;t=182s\">tutorial from Jay Bhatt<\/a> to understand some basics of Plotly\/Dash.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After playing with a number of monitoring tools to keep track of the various sites and devices around the house, since none of them did what I envisioned, I decided to try to take a stab at building my own app. I thought about doing it as a mobile app, but realized a web app [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-551","post","type-post","status-publish","format-standard","hentry","category-programming"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/posts\/551"}],"collection":[{"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/comments?post=551"}],"version-history":[{"count":2,"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/posts\/551\/revisions"}],"predecessor-version":[{"id":555,"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/posts\/551\/revisions\/555"}],"wp:attachment":[{"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/media?parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/categories?post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paynecentral.com\/tompayne\/wp-json\/wp\/v2\/tags?post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}