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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
AdrianCVXABU
New Member

Power BI Python Visual Issue

Hi there,

Power Bi can't run this basic python script displaying this error msg:-

Feedback Type:
Frown (Error)

Timestamp:
2021-10-30T08:36:16.9255936Z

Local Time:
2021-10-30T16:36:16.9255936+08:00

Session ID:
2476cfa7-2655-425a-a137-b39b98a589b6

Release:
October 2021

Product Version:
2.98.1004.0 (21.10) (x64)

Error Message:
No image was created. The Python code didn't result in creation of any visuals. Make sure your Python script results in a plot to the Python default device.

Stack Trace:
Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: No image was created. The Python code didn't result in creation of any visuals. Make sure your Python script results in a plot to the Python default device.
at Microsoft.PowerBI.Client.Windows.Python.PythonScriptHandler.GenerateVisual(ScriptHandlerOptions options)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ScriptVisualCommandFlow.Run(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.TransformDataShapeResult(QueryCommand transformCommand, SemanticQueryDataShapeCommand command, Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ExecuteDataQuery(IQueryResultDataWriter queryResultDataWriter, EngineDataModel engineDataModel, DataQuery query, Int32 queryId, ServiceErrorStatusCode& serviceErrorStatusCode, CancellationToken cancelToken)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ProcessAndWriteSemanticQueryCommands(IQueryResultsWriter queryResultsWriter, IList`1 queries, HashSet`1 pendingQueriesToCancel, EngineDataModel engineDataModel)

Invocation Stack Trace:
at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
at Microsoft.Mashup.Client.UI.Shared.StackTraceInfo..ctor(String exceptionStackTrace, String invocationStackTrace, String exceptionMessage)
at Microsoft.PowerBI.Client.Windows.ErrorHostService.GetErrorDetails(ShowErrorDialogArgs args)
at Microsoft.PowerBI.Client.Windows.ErrorHostService.<>c__DisplayClass4_0.<ShowErrorDialogCore>b__0()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.WindowsFormsSynchronizationContext.Send(SendOrPostCallback d, Object state)
at Microsoft.PowerBI.Client.Windows.Services.UIBlockingService.AllowModalDialogs(Action action)
at Microsoft.PowerBI.Client.Windows.HostServiceDispatcher.<>c__DisplayClass5_0.<ExecuteOnUIThread>b__0(Object t)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.PowerBI.Client.Program.<>c__DisplayClass4_0.<Main>b__1()
at Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass3_0.<HandleExceptionsWithNestedTasks>b__0()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Program.Main(String[] args)


OS Version:
Microsoft Windows NT 10.0.19043.0 (x64 en-US)

CLR Version:
4.7 or later [Release Number = 528372]

Peak Virtual Memory:
102 GB

Private Memory:
640 MB

Peak Working Set:
821 MB

IE Version:
11.789.19041.0

User ID:
38ebba7f-015a-4734-817e-d10303d42943

Workbook Package Info:
1* - en-AU, Query Groups: 0, fastCombine: Disabled, runBackgroundAnalysis: True.

Telemetry Enabled:
True

Snapshot Trace Logs:
C:\Users\aybk\Microsoft\Power BI Desktop Store App\FrownSnapShota0838cea-a0b0-4c3e-a1a9-fc6e2ab2235d.zip

Model Default Mode:
Import

Model Version:
PowerBI_V3

Performance Trace Logs:
C:\Users\aybk\Microsoft\Power BI Desktop Store App\PerformanceTraces.zip

Enabled Preview Features:
PBI_rdlNativeVisual

Disabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_SpanishLinguisticsEnabled
PBI_qnaLiveConnect
PBI_azureMapVisual
PBI_dataPointLassoSelect
PBI_compositeModelsOverAS
PBI_dynamicParameters
PBI_enhancedTooltips

Disabled DirectQuery Options:
TreatHanaAsRelationalSource

Cloud:
GlobalCloud

DPI Scale:
100%

Supported Services:
Power BI

Formulas:


section Section1;

shared #"PC Main" = let
Source = Excel.Workbook(File.Contents("e:\Power Bi\Hg Reboiler Issue\PC_Main.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type datetime}, {"Sample Pt", type text}, {"PC >4um", type number}, {"PC >6um", type number}, {"PC >14um", type number}, {"PC > 21um", type number}, {"PC >38um", type number}, {"PC >70um", type number}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Date", type date}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each true),
#"Removed Duplicates" = Table.Distinct(#"Filtered Rows"),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Removed Duplicates", {"PC >4um", "PC >6um", "PC >14um", "PC > 21um", "PC >38um", "PC >70um"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns",{{"Attribute", "Particle Count Size"}, {"Value", "Particle Count Value"}}),
#"Pivoted Column" = Table.Pivot(#"Renamed Columns", List.Distinct(#"Renamed Columns"[#"Particle Count Size"]), "Particle Count Size", "Particle Count Value", List.Sum),
#"Renamed Columns1" = Table.RenameColumns(#"Pivoted Column",{{"PC > 21um", "PC >21um"}}),
#"Unpivoted Only Selected Columns1" = Table.Unpivot(#"Renamed Columns1", {"PC >4um", "PC >6um", "PC >14um", "PC >21um", "PC >38um", "PC >70um"}, "Attribute", "Value"),
#"Renamed Columns2" = Table.RenameColumns(#"Unpivoted Only Selected Columns1",{{"Attribute", "Particle Count Size"}}),
#"Replaced Value" = Table.ReplaceValue(#"Renamed Columns2","009BN-2001","009BN2001",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","009BN-2006","009BN2006",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","009BN-5010","009BN5010",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","010BN-1001","010BN1001",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value4" = Table.ReplaceValue(#"Replaced Value3","009BN-5009","009BN5009",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value5" = Table.ReplaceValue(#"Replaced Value4","209BN-5015","209BN5015",Replacer.ReplaceText,{"Sample Pt"}),
#"Renamed Columns3" = Table.RenameColumns(#"Replaced Value5",{{"Sample Pt", "Sample_Pt"}})
in
#"Renamed Columns3";

shared Slicer1 = let
Source = Excel.Workbook(File.Contents("e:\Power Bi\Hg Reboiler Issue\Slicer1.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type text}, {"Column2", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Description", type text}, {"Sample Pt", type text}})
in
#"Changed Type1";

shared Slicer2 = let
Source = Excel.Workbook(File.Contents("e:\Power Bi\Hg Reboiler Issue\Slicer2.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type text}, {"Column2", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Particle Count", type text}, {"Description_PC", type text}})
in
#"Changed Type1";

shared #"PC Main 2" = let
Source = Excel.Workbook(File.Contents("e:\Power Bi\Hg Reboiler Issue\PC_Main.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type datetime}, {"Sample Pt", type text}, {"PC >4um", type number}, {"PC >6um", type number}, {"PC >14um", type number}, {"PC > 21um", type number}, {"PC >38um", type number}, {"PC >70um", type number}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Date", type date}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each true),
#"Removed Duplicates" = Table.Distinct(#"Filtered Rows"),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Removed Duplicates", {"PC >4um", "PC >6um", "PC >14um", "PC > 21um", "PC >38um", "PC >70um"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns",{{"Attribute", "Particle Count Size"}, {"Value", "Particle Count Value"}}),
#"Pivoted Column" = Table.Pivot(#"Renamed Columns", List.Distinct(#"Renamed Columns"[#"Particle Count Size"]), "Particle Count Size", "Particle Count Value", List.Sum),
#"Renamed Columns1" = Table.RenameColumns(#"Pivoted Column",{{"PC > 21um", "PC >21um"}}),
#"Unpivoted Only Selected Columns1" = Table.Unpivot(#"Renamed Columns1", {"PC >4um", "PC >6um", "PC >14um", "PC >21um", "PC >38um", "PC >70um"}, "Attribute", "Value"),
#"Renamed Columns2" = Table.RenameColumns(#"Unpivoted Only Selected Columns1",{{"Attribute", "Particle Count Size"}}),
#"Replaced Value" = Table.ReplaceValue(#"Renamed Columns2","009BN-2001","009BN2001",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","009BN-2006","009BN2006",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","009BN-5010","009BN5010",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","010BN-1001","010BN1001",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value4" = Table.ReplaceValue(#"Replaced Value3","009BN-5009","009BN5009",Replacer.ReplaceText,{"Sample Pt"}),
#"Replaced Value5" = Table.ReplaceValue(#"Replaced Value4","209BN-5015","209BN5015",Replacer.ReplaceText,{"Sample Pt"}),
#"Renamed Columns3" = Table.RenameColumns(#"Replaced Value5",{{"Sample Pt", "Sample_Pt"}}),
#"Grouped Rows" = Table.Group(#"Renamed Columns3", {"Sample_Pt"}, {{"Sample_Pt_Ave_Value", each List.Average([Value]), type number}, {"Sample_Pt_Median_Value", each List.Median([Value]), type number}, {"Sample_Pt_Min_Value", each List.Min([Value]), type number}, {"Sample_Pt_Max_Value", each List.Max([Value]), type number}})
in
#"Grouped Rows";

 

This script can run in jupyter notebook succesfully :-

import pandas as pd
data = [['Allan',10],['Bobb',12],['Clark',13]]
df = pd.DataFrame(data,columns=['Name','Age'],dtype=float)
print (df)
 
AdrianCVXABU_0-1635583151971.png

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

"No image was created. The Python code didn't result in creation of any visuals. Make sure your Python script results in a plot to the Python default device."

 

You can't just print your dataframe.  You need to plot its contents somehow.   Use matplotlib - worst case use it to plot the table.

Table Demo — Matplotlib 3.4.3 documentation

 

 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

"No image was created. The Python code didn't result in creation of any visuals. Make sure your Python script results in a plot to the Python default device."

 

You can't just print your dataframe.  You need to plot its contents somehow.   Use matplotlib - worst case use it to plot the table.

Table Demo — Matplotlib 3.4.3 documentation

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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