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.

Python script: Exception has been thrown by the target of an invocation

When attempting to Get Data using Python script, a "Something went wrong" message is displayed. The details are below:

 

Feedback Type:
Frown (Error)

Error Message:
Exception has been thrown by the target of an invocation.

Stack Trace:
Error: Exception has been thrown by the target of an invocation.
at _initialize (ms-pbi://pbi.microsoft.com/ts/Builder/BuilderDialog.js:28:9)
at Anonymous function (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:28218)
at j (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:26852)
at k.fireWith (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:27609)
at e[] (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:28632)
at Anonymous function (ms-pbi://pbi.microsoft.com/ts/FloatingDialog/FloatingDialog.js:37:9)
at n.event.dispatch (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:3:6348)
at r.handle (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:3:3114)

Stack Trace Message:
Exception has been thrown by the target of an invocation.

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.Telemetry.PowerBIUserFeedbackServices.GetStackTraceInfo(Exception e)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass1.<HandleException>b__0()
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
at Microsoft.Mashup.Client.UI.Shared.Ux.FloatingDialog.FloatingDialog.OnError(String message, String stackTrace)
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.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Mashup.Client.UI.Shared.JsExportWrapper.<>c__DisplayClass2.<InvokeMember>b__0()
at Microsoft.Mashup.Client.UI.Windows.JsErrorHandler.WrapInvokeHost(Func`1 invokeHost)
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__FabricatedMethod8(IWindowHandle )
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModalWithInitialReentrancyLock(FloatingDialog floatingDialog, IUIHost uiHost, Func`1 showModalFunction)
at Microsoft.Mashup.Client.UI.Shared.DataImporter.ShowBuilderDialog(PackageReference packageReference, FormulaPath formulaPath, FormulaPartInfo formulaPartInfo, Query query, Action`2 successCallback, Action failureCallback, Boolean isNewQuery, Boolean isFromEditor)
at Microsoft.Mashup.Client.UI.Shared.DataImporter.ResolveQuerySettings(Query query, Action`2 successCallback, Action failureCallback, ResolutionSetting resolutionSetting, Boolean isNewQuery, Boolean isFromEditor)
at Microsoft.Mashup.Client.UI.Shared.DataImporter.TryAddSource(String sourceID, Query& newQuery)
at Microsoft.Mashup.Client.UI.Shared.ConnectHelper.Connect(IWindowHandle owner, IDataSourceTemplateProvider dataSourceTemplateProvider, IUIHost uiHost, ITelemetryService telemetryService, DataImporter dataImporter, CommandUIControlBase commandUIControl, String sourceId, Nullable`1 targetQueryGroupId)
at Microsoft.PowerBI.Client.Windows.Commands.ApplicationCommands.DataImportCommands.Connect(IPowerBIWindowService windowService, IExceptionHandler exceptionHandler, ConnectParameters parameters)
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Windows.Commands.CommandFactory.<>c__DisplayClass42`1.<FromSyncHandlers>b__3f(UICommandParameter`1 p)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.<>c__DisplayClass2.<.ctor>b__0(Object arg)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.<Execute>d__7.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.Execute(Object parameter)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.<System.Windows.Input.ICommand.Execute>d__4.MoveNext()
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute(Object parameter)
at Microsoft.Practices.Prism.Commands.CompositeCommand.Execute(Object parameter)
at Microsoft.PowerBI.Client.Windows.PowerBIDataSourceTemplateProvider.ConnectInternal(String formulaId, Nullable`1 targetQueryGroupId)
at Microsoft.Mashup.Host.Document.DataSourceTemplateProvider.Connect(String formulaId, Nullable`1 targetQueryGroupId)
at Microsoft.Mashup.Client.UI.Shared.Ux.FloatingDialog.SimpleDialog.DataSourceGalleryDialog.<>c__DisplayClass2.<ConnectToDataSource>b__0()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
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__FabricatedMethod8(IWindowHandle )
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.PowerBI.Client.Program.<>c__DisplayClass10.<Main>b__0()
at Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass7.<HandleExceptionsWithNestedTasks>b__6()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Program.Main(String[] args)


Model Default Mode:
Empty

Snapshot Trace Logs:
C:\Users\Kevin\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot795132444.zip

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

Enabled Preview Features:
PBI_variationUIChange
PBI_PythonSupportEnabled

Disabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_newFromWeb
PBI_SpanishLinguisticsEnabled
CustomConnectors
PBI_canvasTooltips
PBI_showIncrementalRefreshPolicy
PBI_compositeModels
PBI_DB2DQ

Disabled DirectQuery Options:
PBI_DirectQuery_Unrestricted
TreatHanaAsRelationalSource

Cloud:
GlobalCloud

Formulas:


section Section1;

shared Query1 = let
Source = Python.Execute(...)
in
Source;

 

Any suggestions on how to correct?

Status: Needs Info
Comments
v-qiuyu-msft
Community Support

Hi @kh100567,

 

Would you please share the Python script you used in Power BI desktop? Which data source do you read data from, is it CSV or other things? 

 

Best Regards,
Qiuyun Yu 

v-qiuyu-msft
Community Support
Status changed to: Needs Info
 
kh100567
Regular Visitor

Hi Qiuyun Yu,

 

There is no Python script as I did not get chance to enter one as the error happened immediately after selection "Python 

 

To replicate:

  1. Open Power BI desktop
  2. Select Home -> Get Data -> More...
  3. In the 'Get Data' dialog, select 'Other -> Python script', and then click 'Connect'

A "Something went wrong" dialog is displayed. The details of the error are at the bottom.

 

Notes:

  • I am using Power BI desktop version 2.61.5192.601 64-bit (August 2018). 
  • I updated from the prior version.
  • This error occurs on two different laptops.

Thanks,

 

Kevin

~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

Feedback Type:
Frown (Error)

Error Message:
Exception has been thrown by the target of an invocation.

Stack Trace:
Error: Exception has been thrown by the target of an invocation.
at _initialize (ms-pbi://pbi.microsoft.com/ts/Builder/BuilderDialog.js:28:9)
at Anonymous function (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:28218)
at j (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:26852)
at k.fireWith (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:27609)
at e[] (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:2:28632)
at Anonymous function (ms-pbi://pbi.microsoft.com/ts/FloatingDialog/FloatingDialog.js:37:9)
at n.event.dispatch (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:3:6348)
at r.handle (ms-pbi://pbi.microsoft.com/OpenSource/jquery/jquery-2.1.1.js:3:3114)

Stack Trace Message:
Exception has been thrown by the target of an invocation.

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.Telemetry.PowerBIUserFeedbackServices.GetStackTraceInfo(Exception e)
at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass1.<HandleException>b__0()
at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
at Microsoft.Mashup.Client.UI.Shared.Ux.FloatingDialog.FloatingDialog.OnError(String message, String stackTrace)
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.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Mashup.Client.UI.Shared.JsExportWrapper.<>c__DisplayClass2.<InvokeMember>b__0()
at Microsoft.Mashup.Client.UI.Windows.JsErrorHandler.WrapInvokeHost(Func`1 invokeHost)
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__FabricatedMethod8(IWindowHandle )
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModalWithInitialReentrancyLock(FloatingDialog floatingDialog, IUIHost uiHost, Func`1 showModalFunction)
at Microsoft.Mashup.Client.UI.Shared.DataImporter.ShowBuilderDialog(PackageReference packageReference, FormulaPath formulaPath, FormulaPartInfo formulaPartInfo, Query query, Action`2 successCallback, Action failureCallback, Boolean isNewQuery, Boolean isFromEditor)
at Microsoft.Mashup.Client.UI.Shared.DataImporter.ResolveQuerySettings(Query query, Action`2 successCallback, Action failureCallback, ResolutionSetting resolutionSetting, Boolean isNewQuery, Boolean isFromEditor)
at Microsoft.Mashup.Client.UI.Shared.DataImporter.TryAddSource(String sourceID, Query& newQuery)
at Microsoft.Mashup.Client.UI.Shared.ConnectHelper.Connect(IWindowHandle owner, IDataSourceTemplateProvider dataSourceTemplateProvider, IUIHost uiHost, ITelemetryService telemetryService, DataImporter dataImporter, CommandUIControlBase commandUIControl, String sourceId, Nullable`1 targetQueryGroupId)
at Microsoft.PowerBI.Client.Windows.Commands.ApplicationCommands.DataImportCommands.Connect(IPowerBIWindowService windowService, IExceptionHandler exceptionHandler, ConnectParameters parameters)
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Windows.Commands.CommandFactory.<>c__DisplayClass42`1.<FromSyncHandlers>b__3f(UICommandParameter`1 p)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.<>c__DisplayClass2.<.ctor>b__0(Object arg)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.<Execute>d__7.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.Execute(Object parameter)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.<System.Windows.Input.ICommand.Execute>d__4.MoveNext()
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Practices.Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute(Object parameter)
at Microsoft.Practices.Prism.Commands.CompositeCommand.Execute(Object parameter)
at Microsoft.PowerBI.Client.Windows.PowerBIDataSourceTemplateProvider.ConnectInternal(String formulaId, Nullable`1 targetQueryGroupId)
at Microsoft.Mashup.Host.Document.DataSourceTemplateProvider.Connect(String formulaId, Nullable`1 targetQueryGroupId)
at Microsoft.Mashup.Client.UI.Shared.Ux.FloatingDialog.SimpleDialog.DataSourceGalleryDialog.<>c__DisplayClass2.<ConnectToDataSource>b__0()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
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__FabricatedMethod8(IWindowHandle )
at Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
at Microsoft.PowerBI.Client.Program.<>c__DisplayClass10.<Main>b__0()
at Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass7.<HandleExceptionsWithNestedTasks>b__6()
at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
at Microsoft.PowerBI.Client.Program.Main(String[] args)


Model Default Mode:
Empty

Snapshot Trace Logs:
C:\Users\Kevin\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot202354086.zip

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

Enabled Preview Features:
PBI_variationUIChange
PBI_PythonSupportEnabled

Disabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_newFromWeb
PBI_SpanishLinguisticsEnabled
CustomConnectors
PBI_canvasTooltips
PBI_showIncrementalRefreshPolicy
PBI_compositeModels
PBI_DB2DQ

Disabled DirectQuery Options:
PBI_DirectQuery_Unrestricted
TreatHanaAsRelationalSource

Cloud:
GlobalCloud

Formulas:


section Section1;

shared Query1 = let
Source = Python.Execute(...)
in
Source;

v-qiuyu-msft
Community Support

Hi @kh100567,

 

Please ensure you already installed Python on the machine which has Power BI desktop run and set the Python directory for Power BI desktop. You can download the latest Python version here: https://www.python.org/downloads/windows/

 

q3.PNG

 

Best Regards,
Qiuyun Yu