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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Problema para gerar visual com script Python 3.7

Estou iniciando estudos para uso do Python com o Power BI e criei uma tabela muito simples e um script básico para gerar um visual de gráfico de barras. O código funciona perfeitamente no Jupyter Notebook mas o Power Bi tem apresentado erros e não gera o visual esperado.

Seguem abaixo informações sobre a tabela, o script utilizado e o erro gerado.

Por favor, peço informar o que devo fazer para corrigir o problema.

 

CONFIGURAÇÃO DO POWER BI PARA PYTHON

Realizadas configurações para habilitar reconhecimento do Python instalado pelo Power BI.

 

TABELA

YearRevenue
2010100000
2011200000
2012300000
2013400000
2014500000

 

SCRIPT PYTHON

# O código a seguir para criar um dataframe e remover as linhas duplicadas sempre é executado e age como um preâmbulo para o script:
# dataset = pandas.DataFrame(Revenue, Year)
# dataset = dataset.drop_duplicates()
# Cole ou digite aqui seu código de script:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.bar(dataset.Year, dataset.Revenue)
plt.show()

 

ERRO APRESENTADO

 

Feedback Type:
Frown (Error)

Timestamp:
2019-06-07T14:35:32.0471395Z

Local Time:
2019-06-07T11:35:32.0471395-03:00

Session ID:
d6452c35-71fc-4f93-a038-da67ff94d9ca

Release:
May 2019

Product Version:
2.69.5467.2151 (19.05) (x64)

Error Message:
Ρуťђбп š¢ґįρť ёгřòŕ.
Traceback (most recent call last):
  File "PythonScriptWrapper.PY", line 2, in <module>
    import os, matplotlib.pyplot, uuid, pandas
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\matplotlib\__init__.py", line 141, in <module>
    from . import cbook, rcsetup
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\matplotlib\cbook\__init__.py", line 33, in <module>
    import numpy as np
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.


Stack Trace:
Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: Ρуťђбп š¢ґįρť ёгřòŕ.
Traceback (most recent call last):
  File "PythonScriptWrapper.PY", line 2, in <module>
    import os, matplotlib.pyplot, uuid, pandas
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\matplotlib\__init__.py", line 141, in <module>
    from . import cbook, rcsetup
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\matplotlib\cbook\__init__.py", line 33, in <module>
    import numpy as np
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.
 ---> Microsoft.PowerBI.Scripting.Python.Exceptions.PythonScriptRuntimeException: Ρуťђбп š¢ґįρť ёгřòŕ.
Traceback (most recent call last):
  File "PythonScriptWrapper.PY", line 2, in <module>
    import os, matplotlib.pyplot, uuid, pandas
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\matplotlib\__init__.py", line 141, in <module>
    from . import cbook, rcsetup
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\matplotlib\cbook\__init__.py", line 33, in <module>
    import numpy as np
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\USERS\XYZ\APPDATA\LOCAL\ANACONDA3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.

   em Microsoft.PowerBI.Scripting.Python.PythonScriptWrapper.RunScript(String originalScript, Int32 timeoutMs)
   em Microsoft.PowerBI.Client.Windows.Python.PythonScriptHandler.GenerateVisual(ScriptHandlerOptions options)
   --- Fim do rastreamento de pilha de exceções internas ---
   em Microsoft.PowerBI.Client.Windows.Python.PythonScriptHandler.GenerateVisual(ScriptHandlerOptions options)
   em Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
   em Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.Run(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
   em Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.TransformDataShapeResult(QueryCommand transformCommand, SemanticQueryDataShapeCommand command, Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
   em Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ExecuteDataQuery(IQueryResultDataWriter queryResultDataWriter, EngineDataModel engineDataModel, DataQuery query, Int32 queryId, ServiceErrorStatusCode& serviceErrorStatusCode, CancellationToken cancelToken)
   em Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ProcessAndWriteSemanticQueryCommands(IQueryResultsWriter queryResultsWriter, IList`1 queries, HashSet`1 pendingQueriesToCancel, EngineDataModel engineDataModel)

Invocation Stack Trace:
   em Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
   em Microsoft.Mashup.Client.UI.Shared.StackTraceInfo..ctor(String exceptionStackTrace, String invocationStackTrace, String exceptionMessage)
   em Microsoft.PowerBI.Client.Windows.ErrorHostService.GetErrorDetails(ShowErrorDialogArgs args)
   em Microsoft.PowerBI.Client.Windows.ErrorHostService.<>c__DisplayClass2_0.<<ShowErrorDialog>b__0>d.MoveNext()
   em System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   em Microsoft.PowerBI.Client.Windows.ErrorHostService.<>c__DisplayClass2_0.<ShowErrorDialog>b__0()
   em Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass1_0`1.<SendAndMarshalExceptions>b__0()
   em Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass0_1.<SendAndMarshalExceptions>b__0(Object null)
   em System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   em System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   em System.Delegate.DynamicInvokeImpl(Object[] args)
   em System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   em System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   em System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   em System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   em System.Windows.Forms.Control.WndProc(Message& m)
   em System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   em System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   em Microsoft.Mashup.Client.UI.Shared.WebDialogs.WebDialog.<>n__0(IWindowHandle owner)
   em Microsoft.Mashup.Client.UI.Shared.WindowManager.ShowModal[T](T dialog, Func`1 showModalFunction)
   em Microsoft.PowerBI.Client.Program.<>c__DisplayClass4_0.<Main>b__1()
   em Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass3_0.<HandleExceptionsWithNestedTasks>b__0()
   em Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
   em Microsoft.PowerBI.Client.Program.Main(String[] args)


OS Version:
Microsoft Windows NT 10.0.17134.0 (x64 pt-BR)

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

Peak Virtual Memory:
38.2 GB

Private Memory:
403 MB

Peak Working Set:
576 MB

IE Version:
11.648.17134.0

User ID:
6bf9135a-5cd4-4ca3-95ef-41c48a282720

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

Telemetry Enabled:
True

Model Default Mode:
Import

Snapshot Trace Logs:
C:\Users\XYZ\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot1386012828.zip

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

Enabled Preview Features:
PBI_shapeMapVisualEnabled

Disabled Preview Features:
PBI_SpanishLinguisticsEnabled
PBI_NewWebTableInference
PBI_showIncrementalRefreshPolicy
PBI_showManageAggregations
PBI_improvedFilterExperience
PBI_qnaLiveConnect
PBI_keyDrivers

Disabled DirectQuery Options:
TreatHanaAsRelationalSource

Cloud:
GlobalCloud

DPI Scale:
100%

Supported Services:
Power BI

Formulas:


section Section1;

shared Planilha1 = let
    Source = Excel.Workbook(File.Contents("C:\Users\XYZ\Downloads\HR Analytics\Teste.xlsx"), null, true),
    Planilha1_Sheet = Source{[Item="Planilha1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Planilha1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Year", Int64.Type}, {"Revenue", Int64.Type}})
in
    #"Changed Type";

 

 

 

 

 

Status: New
Comments
v-qiuyu-msft
Community Support

Hi @delamora

 

Would you please clarify the issue in English so we can understand the issue better? 

 

Best Regards,
Qiuyun Yu