cancel
Showing results for 
Search instead for 
Did you mean: 

python script error

Hello,

 

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. 

 

Regards,

Dave

Status: New
Comments
Moderator

Hi @djanez,

 

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: 

 

q5.PNG

 

Best Regards,
Qiuyun Yu 

Visitor

Hi @v-qiuyu-msft,

 

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.

2018-10-17_12h34_24.jpg

 

import numpy as np
import lifelines as ll
from lifelines.estimation import KaplanMeierFitter
kmf = 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
rcParams['figure.figsize']=10, 5

f = dataset.type==1
T = 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:

2018-10-17_12h27_22.jpg

Moderator

Hi @djanez,

 

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

rcParams['figure.figsize']=10, 5

f = True
T = dataset['Time']
C = dataset['Event']

kmf.fit(T, event_observed=C)
kmf.survival_function_.plot(title='Event over Time1') 
ax = kmf.plot()
ax.get_figure().savefig("myfigure.png") 

 

w6.PNG

 

 

Best Regards,
Qiuyun Yu