Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Script Run Time Error for a Python Chart in Power BI Web Version

Hi,

 

I am developing a python chart in my power bi dashboard. The chart works in the PBI desktop version file. However, when I publish the dashboard, I got a script run time error message. See the detail of the error below. Can you help to identify what the issue is here?

 

Script Runtime Error

File "C:\Python\lib\site-packages\matplotlib\backends\backend_agg.py", line 514, in print_png

FigureCanvasAgg.draw(self)

File "C:\Python\lib\site-packages\matplotlib\backends\backend_agg.py", line 393, in draw

self.figure.draw(self.renderer)

File "C:\Python\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Python\lib\site-packages\matplotlib\figure.py", line 1736, in draw

renderer, self, artists, self.suppressComposite)

File "C:\Python\lib\site-packages\matplotlib\image.py", line 137, in _draw_list_compositing_images

a.draw(renderer)

File "C:\Python\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Python\lib\site-packages\matplotlib\axes\_base.py", line 2630, in draw

mimage._draw_list_compositing_images(renderer, self, artists)

File "C:\Python\lib\site-packages\matplotlib\image.py", line 137, in _draw_list_compositing_images

a.draw(renderer)

File "C:\Python\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Python\lib\site-packages\matplotlib\text.py", line 685, in draw

bbox, info, descent = textobj._get_layout(renderer)

File "C:\Python\lib\site-packages\matplotlib\text.py", line 278, in _get_layout

key = self.get_prop_tup(renderer=renderer)

File "C:\Python\lib\site-packages\matplotlib\text.py", line 846, in get_prop_tup

x, y = self.get_unitless_position()

File "C:\Python\lib\site-packages\matplotlib\text.py", line 828, in get_unitless_position

x = float(self.convert_xunits(self._x))

File "C:\Python\lib\site-packages\matplotlib\artist.py", line 178, in convert_xunits

return ax.xaxis.convert_units(x)

File "C:\Python\lib\site-packages\matplotlib\axis.py", line 1576, in convert_units

f'units: {x!r}') from e

matplotlib.units.ConversionError: Failed to convert value(s) to axis units: '2019-02'


Please try again later or contact support. If you contact support, please provide these details.
Activity ID: 75d0528c-d810-4f59-b332-376f6e0833df
Request ID: 06bd3e9f-2fd3-6b29-877e-848c3edf4272
Correlation ID: 1e9148d4-c56e-1c50-9fb1-d0d0833c6f41
Time: Tue Aug 11 2020 15:04:52 GMT-0700 (Pacific Daylight Time)
Service version: 13.0.14066.71
Client version: 2008.1.02249-train
Cluster URI: https://wabi-west-us-redirect.analysis.windows.net/

 

Thanks,

Andika

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found out the issue. The data label was not using the correct converted date value for 'Year_Mth' column. So, I revised it to dateset['Date'] and now it is working.

 

plt.text(dataset['Date'].iloc[i],dataset['Remaining_Balance'].iloc[i] + slider,dataset['Remaining_Balance'].iloc[i],color='black')

 

🙂

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

This is the code that I used to develop the chart if it will help your review. Thanks!

 

import pandas as pd
import matplotlib.pyplot as plt
import datetime
import seaborn as sns
import numpy as np

dataset['Date'] = pd.to_datetime(dataset.Year_Mth)
dataset['Date'].sort_values(ascending=True)
 
#plt.figure(figsize = (35,15))
plt.xlim(dataset['Date'].iloc[-18], dataset['Date'].iloc[-1])
 
sns.lineplot(data=dataset, x='Date', y='Remaining_Balance', linewidth=4, marker='D', markersize='10', color='lightcoral', markeredgecolor='darkblue')

slider = 5
for i in range(dataset.shape[0]-18,dataset.shape[0]):
plt.text(dataset['Year_Mth'].iloc[i],dataset['Remaining_Balance'].iloc[i] + slider,dataset['Remaining_Balance'].iloc[i],color='black')

plt.show()


dataset['Date'] = pd.to_datetime(dataset.Year_Mth)

 

You need to make sure that Year_Mth has a format that can be successfully converted to a datetime. Across your entire dataset.

Anonymous
Not applicable

I found out the issue. The data label was not using the correct converted date value for 'Year_Mth' column. So, I revised it to dateset['Date'] and now it is working.

 

plt.text(dataset['Date'].iloc[i],dataset['Remaining_Balance'].iloc[i] + slider,dataset['Remaining_Balance'].iloc[i],color='black')

 

🙂

Anonymous
Not applicable

The chart was successfully shown in the desktop version.

CAPA Balance Desktop Version.jpg

 

I changed the format of the Year-Mth column from text into date "yyyy-mm". Still getting the Script Run Time Error. 

Year-Mth Column Date Setting as YYYY-MM.jpg

amitchandak
Super User
Super User

@Anonymous , for power bi service, Gateway should also be working - check https://powerbi.microsoft.com/en-us/blog/python-visualizations-in-power-bi-service/

lbendlin
Super User
Super User

You need to convert your YearMonth string into a numeric value, for example Year*100+Month

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.