cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
numersoz
Helper III
Helper III

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


1 ACCEPTED SOLUTION
numersoz
Helper III
Helper 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. 

View solution in original post

5 REPLIES 5
aliounediop
New Member

Hello

I did all recommended steps but they didnt help,i am still facing the issue when trying to run python in PowerBI

jbbonifa
New 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

numersoz
Helper III
Helper 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. 

View solution in original post

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 plt
plt.plot(dataset.x, dataset,y1)
plt.show()


HERE is my ERROR: 

Feedback Type:
Frown (Error)

Timestamp:
2020-04-04T04:12:40.3567733Z

Local Time:
2020-04-03T23:12:40.3567733-05:00

Session ID:
abc45894-f59b-4ff9-b2ff-2d2d32957617

Release:
March 2020

Product 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 defined

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)
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 GB

Private Memory:
831 MB

Peak Working Set:
895 MB

IE Version:
11.719.18362.0

User ID:
dd691e0e-caef-4d47-9f6d-633f1fced5f5

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

Telemetry Enabled:
True

Snapshot Trace Logs:
C:\Users\marke\Microsoft\Power BI Desktop Store App\FrownSnapShot1118972768.zip

Model Default Mode:
Composite

Model Version:
PowerBI_V1

Is Report V3 Models Enabled:
False

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

Enabled Preview Features:
PBI_showMinervaRibbon
PBI_showMinervaViewNavigator

Disabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_SpanishLinguisticsEnabled
PBI_NewWebTableInference
PBI_qnaLiveConnect
PQ_AIInsightsFunctionBrowser
PBI_realTimeRefresh
PBI_v3Models
PBI_decompositionTree
PBI_themeDialog
PBI_hierarchicalSlicerCreation

Disabled DirectQuery Options:
TreatHanaAsRelationalSource

Cloud:
GlobalCloud

DPI Scale:
150%

Supported Services:
Power BI

Formulas:


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";

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.

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors