Hi,
I want to simply create a plot using actions.py
I am getting below error:
Exception occurred while handling uri: 'http://app:5055/webhook'
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/sanic/app.py", line 931, in handle_request
response = await response
File "/opt/venv/lib/python3.8/site-packages/rasa_sdk/endpoint.py", line 104, in webhook
result = await executor.run(action_call)
File "/opt/venv/lib/python3.8/site-packages/rasa_sdk/executor.py", line 398, in run
action(dispatcher, tracker, domain)
File "/app/actions/actions.py", line 83, in run
fig.savefig("./actions/neww.png")
File "/opt/venv/lib/python3.8/site-packages/matplotlib/figure.py", line 2311, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2210, in print_figure
result = print_method(
File "/opt/venv/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 1639, in wrapper
return func(*args, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 510, in print_png
mpl.image.imsave(
File "/opt/venv/lib/python3.8/site-packages/matplotlib/image.py", line 1611, in imsave
image.save(fname, **pil_kwargs)
File "/opt/venv/lib/python3.8/site-packages/PIL/Image.py", line 2237, in save
fp = builtins.open(filename, "w+b")
PermissionError: [Errno 13] Permission denied: './actions/neww.png'
Here is my actions.py file:
class ActionForecastRisk(Action):
def name(self) -> Text:
return "action_forecast_xyz"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
import seaborn as sns
import matplotlib.pyplot as plt
l = [41, 44, 46, 46, 47, 47, 48, 48, 49, 51, 52, 53, 53, 53, 53, 55, 55, 55,
55, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58,
58, 59, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, 61,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62,
62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 65,
65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66, 66, 66,
67, 67, 67, 67, 67, 67, 67, 67, 68, 68, 68, 68, 68, 69, 69, 69, 70, 70,
70, 70, 71, 71, 71, 71, 71, 72, 72, 72, 72, 73, 73, 73, 73, 73, 73, 73,
74, 74, 74, 74, 74, 75, 75, 75, 76, 77, 77, 78, 78, 79, 79, 79, 79, 80,
80, 80, 80, 81, 81, 81, 81, 83, 84, 84, 85, 86, 86, 86, 86, 87, 87, 87,
87, 87, 88, 90, 90, 90, 90, 90, 90, 91, 91, 91, 91, 91, 91, 91, 91, 92,
92, 93, 93, 93, 94, 95, 95, 96, 98, 98, 99, 100, 102, 104, 105, 107, 108,
109, 110, 110, 113, 113, 115, 116, 118, 119, 121]
plt = sns.distplot(l, kde=True, rug=False)
fig = plt.get_figure()
fig.savefig("./actions/neww.png")
msg = "hiiiii"
dispatcher.utter_message(text=msg, image = "./actions/neww.png")
return []