I've just started trying to use the Python visual in Power BI, but am getting an error whenever I try to load data.
from PyQt4 import QtCore, QtGui
ImportError: DLL load failed: The specified module could not be found.
This error occurs regardless of the data I am using or the script I try to run. I am not trying to import these modules, which makes the issue more puzzling.
For reference, I am using Anaconda with Python3.5 (I believe .5.6). I have pyqt 4.11.4 and sip 4.16.9 installed, as well.
Please someone advise on how I might be able to troubleshoot this.
1. When you add the Python visual in the report, which Python script do you run? Please share the script.
2. Please run the Python script used in Power BI desktop on Power BI side to see if the same issue occurs.
3. In Power BI desktop, ensure the directory for Python has been set correctly:
Best Regards,Qiuyun Yu
For reference, I am trying to get to the point of creating a plot of the Kaplan-Meier curve using my data, as shown in this tutorial: https://plot.ly/ipython-notebooks/survival-analysis-r-vs-python/
1. I have tried running my own script (see below), as well as the script found in the tutorial here: https://docs.microsoft.com/en-us/power-bi/desktop-python-visuals.
import numpy as npimport lifelines as llfrom lifelines.estimation import KaplanMeierFitterkmf = KaplanMeierFitter()
import matplotlib.pyplot as pltimport plotly.plotly as pyimport plotly.tools as tlsfrom plotly.graph_objs import *
from pylab import rcParamsrcParams['figure.figsize']=10, 5
f = dataset.type==1T = dataset[f]['Time']C = dataset[f]['Event']
kmf.fit(T, event_observed=C)kmf.plot(title='Event over Time1')
2. I am not sure what you mean "on the Power BI side". I am trying to build this visual in Python because I cannot do what I need to in Power BI using my dataset.
3. My python directory is through Anaconda3:
Please modify your script like below:
import numpy as np
import pandas as pd
import lifelines as ll
from lifelines.estimation import KaplanMeierFitter
import matplotlib.pyplot as plt
import plotly.plotly as py
import plotly.tools as tls
from plotly.graph_objs import *
from pylab import rcParams
kmf = KaplanMeierFitter()
f = True
T = dataset['Time']
C = dataset['Event']
kmf.survival_function_.plot(title='Event over Time1')
ax = kmf.plot()
I solved my DLL load failure issues by replacing Anaconda3 with WinPython.