cancel
Showing results for 
Search instead for 
Did you mean: 

Can't display python visual

Dear Community,

I cannot seem to use python visuals (anymore), however it works for most of my colleagues in our organisation.

Any python visual (even the most simple example scatter plot with simple sample data, see https://docs.microsoft.com/en-us/power-bi/desktop-python-visuals ) does not work, and I get this error instead:

PowerBI_PythonVisual_error.jpg

 

 

 

 

 

 

 

 

 

 

 

 

I have python 3.6.5 installed.

 

Any ideas?

 

Thanks!

 

Details of the error message:

 

 

Feedback Type:
Frown (Error)
Timestamp:
2019-10-29T10:07:39.2968466Z
Local Time:
2019-10-29T10:07:39.2968466+00:00
Session ID:
9557d664-d1da-48a5-ad25-298e96d1679d
Release:
October 2019
Product Version:
2.74.5619.862 (19.10) (x64)
Error Message:
An exception of type Microsoft.PowerBI.ExploreServiceCommon.ContainPIIException occured.
Stack Trace:
Microsoft.PowerBI.ExploreServiceCommon.ContainPIIException: ScriptVisualCommandFlow-GenerateVisualError ---> Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: The Python process ended unexpectedly, so the visual can't be displayed. Please try running it again. ---> System.ComponentModel.Win32Exception: The file or directory is corrupted and unreadable
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at Microsoft.PowerBI.Scripting.Python.PythonScriptWrapper.GetPythonVersionAndEmitTrace(String pythonExePath, Int32 scriptHash)
   at Microsoft.PowerBI.Scripting.Python.PythonScriptWrapper.RunScript(String originalScript, Int32 timeoutMs)
   at Microsoft.PowerBI.Client.Windows.Python.PythonScriptHandler.GenerateVisual(ScriptHandlerOptions options)
   --- End of inner exception stack trace ---
   at Microsoft.PowerBI.Client.Windows.Python.PythonScriptHandler.GenerateVisual(ScriptHandlerOptions options)
   at Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
   --- End of inner exception stack trace ---
   at Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
   at Microsoft.PowerBI.ExploreServiceCommon.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__DisplayClass2_0.<<ShowErrorDialog>b__0>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.PowerBI.Client.Windows.ErrorHostService.<>c__DisplayClass2_0.<ShowErrorDialog>b__0()
   at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass1_0`1.<SendAndMarshalExceptions>b__0()
   at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass0_1.<SendAndMarshalExceptions>b__0(Object null)
   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.WebDialogs.WebDialog.<>n__0(IWindowHandle owner)
   at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
   at Microsoft.PowerBI.Client.Program.<>c__DisplayClass2_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.18362.0 (x64 en-GB)
CLR Version:
4.7 or later [Release Number = 528040]
Peak Virtual Memory:
42.4 GB
Private Memory:
2.14 GB
Peak Working Set:
4.49 GB
IE Version:
11.418.18362.0
User ID:
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Workbook Package Info:
1* - en-GB, Query Groups: 10, fastCombine: Disabled, runBackgroundAnalysis: True.
Telemetry Enabled:
False
Model Default Mode:
Composite

 

 

 

 

 

 

 

Status: New
Comments
Regular Visitor

My issue with this turned out to be an incorrectly configured IDE installation. I couldn't get it to work with MS's instructions, but these worked for me. The IDE installation I needed is further detailed here. These instructions only apply to Python, but it may be the same problem with R scripting.

Frequent Visitor

Now R, ggplot2 works fine for me.

Resolver III

Hi, my conclusion: This error message is just saying "something's wrong in your code but I won't tell you what or where".

 

In my case the error occurs when I thought I created the frame with the built in code:

 
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
dataset <- data.frame(GBR, SWE, TUR)
# dataset <- unique(dataset)
# Paste or type your script code here:
library(corrplot)
corrplot(cor(dataset))
 
error.PNG 
-------------------
But if I create the frame myself:
 
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
#dataset <- data.frame(GBR, SWE, TUR)
# dataset <- unique(dataset)
# Paste or type your script code here:
gbr <- dataset$GBR
swe <- dataset$SWE
tur <- dataset$TUR
dataframe <- data.frame(gbr, swe, tur)
library(corrplot)
corrplot(cor(dataframe))
 
corrplot.PNG
it works.
Regular Visitor

Same error using a Spline Chart 

I am using R version 3.5.3

Helper I

same error

Helper I

I have set python IDE (default of OS) and version (Anaconda). I run a simple dataframe transformation in python visualisation and I am getting an error.

 

I am using power bi desktop and python 3.7. The code in python visualisation is also very simple:

 

Code:

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
# import pandas
# dataset = pandas.DataFrame(REPORTDATE+Time, SECE Group, Overall SECE Availability product)
# dataset = dataset.drop_duplicates()

# Paste or type your script code here:
# dataset.head()
import pandas as pd

# print('done')
sorted_data = dataset.sort_values(by=['SECE Group','REPORTDATE+Time'])

for i in range(0,len(sorted_data['Overall SECE Availability product'])):
sorted_data.at[i,'Overall SECE Availability product'] = float(sorted_data['Overall SECE Availability product'][i][:-1])

sorted_data['new'] = sorted_data.iloc[:,2].rolling(window=3).mean()

sorted_data

 

Feedback Type:
Frown (Error)

Timestamp:
2020-08-04T12:09:01.4025110Z

Local Time:
2020-08-04T13:09:01.4025110+01:00

Session ID:
2c72290a-16b1-47f9-aa25-1433421c06d9

Release:
November 2019

Product Version:
2.75.5649.961 (19.11) (x64)

Error Message:
An exception of type Microsoft.PowerBI.ExploreServiceCommon.ContainPIIException occured.

Stack Trace:
Microsoft.PowerBI.ExploreServiceCommon.ContainPIIException: ScriptVisualCommandFlow-GenerateVisualError ---> 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.ExploreServiceCommon.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
--- End of inner exception stack trace ---
at Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
at Microsoft.PowerBI.ExploreServiceCommon.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__DisplayClass2_0.<<ShowErrorDialog>b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.PowerBI.Client.Windows.ErrorHostService.<>c__DisplayClass2_0.<ShowErrorDialog>b__0()
at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass1_0`1.<SendAndMarshalExceptions>b__0()
at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass0_1.<SendAndMarshalExceptions>b__0(Object null)
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.WebDialogs.WebDialog.<>n__0(IWindowHandle owner)
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.PowerBI.Client.Program.<>c__DisplayClass2_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.17763.0 (x64 en-GB)

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

Peak Virtual Memory:
38.5 GB

Private Memory:
426 MB

Peak Working Set:
616 MB

IE Version:
11.1339.17763.0

User ID:
39facb86-23b5-4f3f-b853-1f61d1c936aa

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

Telemetry Enabled:
True

Snapshot Trace Logs:
C:\Users\vijay.shankar\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot1966202525.zip

Model Default Mode:
Import

Performance Trace Logs:
C:\Users\vijay.shankar\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip

Disabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_SpanishLinguisticsEnabled
PBI_NewWebTableInference
PBI_showIncrementalRefreshPolicy
PBI_qnaLiveConnect
PQ_AIInsightsFunctionBrowser
PBI_realTimeRefresh
PBI_userFavoriteResourcePackagesEnabled
PBI_personalVisualizationPaneEnabled
PBI_QueryDiagnostics
PBI_showMinervaRibbon
PBI_showMinervaViewNavigator
PBI_decompositionTree

Disabled DirectQuery Options:
TreatHanaAsRelationalSource

Cloud:
GlobalCloud

DPI Scale:
100%

Supported Services:
Power BI

Formulas:


section Section1;

shared #"Tag Master Table" = let
Source = Access.Database(File.Contents("C:\Users\vijay.shankar\OneDrive - Xodus Group\Projects\2020\Department Interaction\TSR\SECE PS Tracking\A - SC Maintenance Tracker Tool R&D Project\TestData.accdb"), [CreateNavigationProperties=true]),
#"_Tag Master Table" = Source{[Schema="",Item="Tag Master Table"]}[Data]
in
#"_Tag Master Table";

shared #"Tag vs SECEs" = let
Source = Access.Database(File.Contents("C:\Users\vijay.shankar\OneDrive - Xodus Group\Projects\2020\Department Interaction\TSR\SECE PS Tracking\A - SC Maintenance Tracker Tool R&D Project\TestData.accdb"), [CreateNavigationProperties=true]),
#"_Tag vs SECEs" = Source{[Schema="",Item="Tag vs SECEs"]}[Data]
in
#"_Tag vs SECEs";

shared WOs = let
Source = Access.Database(File.Contents("C:\Users\vijay.shankar\OneDrive - Xodus Group\Projects\2020\Department Interaction\TSR\SECE PS Tracking\A - SC Maintenance Tracker Tool R&D Project\TestData.accdb"), [CreateNavigationProperties=true]),
_WOs = Source{[Schema="",Item="WOs"]}[Data],
#"Added Custom" = Table.AddColumn(_WOs, "No of SC APM Fails & Failfixs", each if [WORKTYPE] = "APM" and ([CNRINSPRESULT] = "FAIL" or [CNRINSPRESULT]="FAILFIX") and ([HASRAF]="Y") then 1 else 0),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "No of SC CM Fails", each if ([HASRAF] = "Y" and [WORKTYPE] = "CM" and [CNRINSPRESULT] = "FAIL") then 1 else 0)
in
#"Added Custom1";

shared Tag_vs_SECEs2 = let
Source = Excel.Workbook(File.Contents("C:\Users\vijay.shankar\OneDrive - Xodus Group\Projects\2020\Department Interaction\TSR\SECE PS Tracking\A - SC Maintenance Tracker Tool R&D Project\Tag vs SECEs.xlsx"), null, true),
Tag_vs_SECEs_Sheet = Source{[Item="Tag_vs_SECEs",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Tag_vs_SECEs_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"LOCATION", type text}, {"SECE Group", type text}, {"RBD Group", type text}, {"Population", Int64.Type}})
in
#"Changed Type";

shared #"RBD Configurations" = let
Source = Excel.Workbook(File.Contents("C:\Users\vijay.shankar\OneDrive - Xodus Group\Projects\2020\Department Interaction\TSR\SECE PS Tracking\A - SC Maintenance Tracker Tool R&D Project\RBD Group Test intervals.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",{{"Relevant PS", type text}, {"RBD Grouping", type text}, {"Count of LOCATIONS", Int64.Type}, {"Sum of Pop Counts", Int64.Type}, {"Assumed Testing Frequency", Int64.Type}, {"Configuration", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,180,Replacer.ReplaceValue,{"Assumed Testing Frequency"})
in
#"Replaced Value";

shared Moving_Average = let
Source = Excel.Workbook(File.Contents("C:\Users\vijay.shankar\OneDrive - Xodus Group\Projects\2020\Department Interaction\TSR\SECE PS Tracking\A - SC Maintenance Tracker Tool R&D Project\Moving_Average.xlsx"), null, true),
Moving_Average_Sheet = Source{[Item="Moving_Average",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Moving_Average_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Year", Int64.Type}, {"Quarter", type text}, {"Month", type text}, {"Day", Int64.Type}, {"SECE Group", type text}, {"Overall SECE Availability product", Percentage.Type}, {"Moving 3 Months Average", Percentage.Type}})
in
#"Changed Type";