Forum Discussion
Power BI Python ADO.NET: Python Script Error
Hi,
When using Python in Power BI, I get the following error, I've tried Python 3.5, 3.8 and Anaconda distro. All of them are giving me this error. My Power BI version is 2.74.5619.862 64-bit (October 2019)
Details: "ADO.NET: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 10, in <module>
completedData = dataset.fillna(method='backfill', inplace=False)
NameError: name 'dataset' is not defined
Ok problem solved! After blaming it on Python and doing many installs and uninstall with trying different version of Python, it was Power BI after all. I had to uninstall and install Power BI and now it is working.
9 Replies
- numersozHelper III
Ok problem solved! After blaming it on Python and doing many installs and uninstall with trying different version of Python, it was Power BI after all. I had to uninstall and install Power BI and now it is working.
- markvogtNew Member
GREAT that you think you've "solved" this aggravating error (I have just encountered it for the first time TODAY)...
... but it's INSANE to think UNINSTALL-then-REINSTALL is actually a "solution" 😮 !!!! @ POWERBI GODS - what's the REAL solution here ??? I can'te even get a simple numeric x,y plot work work, with only 4 lines of python code, so SOMETHING IS VERY WRONG HERE...
PLEASE PLEASE HELP, and DON'T-FOR-THE-LOVE-OF-ALL-THAT-IS-HOLY tell me "uninstall then reinstall PowerBI".
You MAY as well tell me "get a new LAPTOP" is a "solution" - !@#$%^&*...-Mark in North Aurora IL
HERE is my script:# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:dataset = pandas.DataFrame(x, y1)dataset = dataset.drop_duplicates()# Paste or type your script code here:import matplotlib.pyplot as pltplt.plot(dataset.x, dataset,y1)plt.show()
HERE is my ERROR:Feedback Type:
Frown (Error)Timestamp:
2020-04-04T04:12:40.3567733ZLocal Time:
2020-04-03T23:12:40.3567733-05:00Session ID:
abc45894-f59b-4ff9-b2ff-2d2d32957617Release:
March 2020Product Version:
2.79.5768.721 (20.03) (x64)Error Message:
Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 15, in <module>
dataset = pandas.DataFrame(x, y1)
NameError: name 'x' is not defined
Stack Trace:
Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 15, in <module>
dataset = pandas.DataFrame(x, y1)
NameError: name 'x' is not defined
---> Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException: Python script error.
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 15, in <module>
dataset = pandas.DataFrame(x, y1)
NameError: name 'x' is not definedat 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)
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-US)CLR Version:
4.7 or later [Release Number = 528040]Peak Virtual Memory:
38.5 GBPrivate Memory:
831 MBPeak Working Set:
895 MBIE Version:
11.719.18362.0User ID:
dd691e0e-caef-4d47-9f6d-633f1fced5f5Workbook Package Info:
1* - en-US, Query Groups: 0, fastCombine: Disabled, runBackgroundAnalysis: True.Telemetry Enabled:
TrueSnapshot Trace Logs:
C:\Users\marke\Microsoft\Power BI Desktop Store App\FrownSnapShot1118972768.zipModel Default Mode:
CompositeModel Version:
PowerBI_V1Is Report V3 Models Enabled:
FalsePerformance Trace Logs:
C:\Users\marke\Microsoft\Power BI Desktop Store App\PerformanceTraces.zipEnabled Preview Features:
PBI_showMinervaRibbon
PBI_showMinervaViewNavigatorDisabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_SpanishLinguisticsEnabled
PBI_NewWebTableInference
PBI_qnaLiveConnect
PQ_AIInsightsFunctionBrowser
PBI_realTimeRefresh
PBI_v3Models
PBI_decompositionTree
PBI_themeDialog
PBI_hierarchicalSlicerCreationDisabled DirectQuery Options:
TreatHanaAsRelationalSourceCloud:
GlobalCloudDPI Scale:
150%Supported Services:
Power BIFormulas:
section Section1;shared WELLNESS_STATUS = let
Source = Sql.Databases("rdbmsmvgeneral.database.windows.net"),
#"DB-MV-General" = Source{[Name="DB-MV-General"]}[Data],
dbo_WELLNESS_STATUS = #"DB-MV-General"{[Schema="dbo",Item="WELLNESS_STATUS"]}[Data]
in
dbo_WELLNESS_STATUS;shared #"Simple1-x--2-y-DataSet-01" = let
Source = Csv.Document(File.Contents("C:\Users\marke\Downloads\Simple1-x--2-y-DataSet-01.csv"),[Delimiter=",", Columns=4, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"id", Int64.Type}, {"x", Int64.Type}, {"y1", Int64.Type}, {"y2", Int64.Type}})
in
#"Changed Type";- numersozHelper III
This might not be the best approch, but from my experience I learned not to use Anaconda Python with Power BI. So with Power BI I only use regular Python installation.
- AnonymousNot applicable
Hello
I did all recommended steps but they didnt help,i am still facing the issue when trying to run python in PowerBI
- MaryamSalehiNew Member
When you add fields to visual, there is a line scripting # dataset.dataframe(addedfields). This line automaticly added and is commented(started with #). You should not make it uncommented. Just leave it in the way it is, and add your other visualization codes
 
- janetmzahnerNew Member
Thank you so much! I've been banging my head against the wall for 2 days trying to figure this out. The solution described in the blog post was perfect.
- jbbonifaNew Member
I fixed errors like this by adding the following paths to BOTH my USER PATH and SYSTEM PATH environment variables:
C:\Users\[user]\AppData\Local\Continuum\anaconda3
C:\Users\[user]\AppData\Local\Continuum\anaconda3\Library\mingw-w64\bin
C:\Users\[user]\AppData\Local\Continuum\anaconda3\Scripts
C:\Users\[user]\AppData\Local\Continuum\anaconda3\Library\bin - vandromartinsFrequent Visitor
I was having this issue until I debugged my Python script and enter just the first line where I declare my datasets.
But note I've done that on the command line of Power Query itself, not in the Python script: