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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Arvins
Regular Visitor

Python script for Power BI Desktop visualization does not work

Hello, everyone!

Now I am studying Python and as I previously worked with Power BI, I tried to test how it would be to run Python vizualization script in Power BI Desktop.

The script I tried to run is written using Python plotly library and works perfect on Jupyter and there is nothing special about it:

import pandas as pd

import matplotlib.pyplot as plt

import plotly.express as px

import plotly.graph_objects as go

 

df = pd.read_csv('C:\\path.csv');

df['open_time_timeformat'] = pd.to_datetime(df['open_time'], unit='ms').dt.strftime('%Y-%m-%d %H:%M:%S')

df['close_time_timeformat'] = pd.to_datetime(df['close_time'], unit='ms').dt.strftime('%Y-%m-%d %H:%M:%S')

df['day'] = pd.to_datetime(df['close_time'], unit='ms').dt.strftime('%d')

df['difference']= df['quote_volume'] - df['taker_buy_quote_volume']

fig = go.Figure(data=[go.Candlestick(x=df['close_time_timeformat'],

                open=df['open'],

                high=df['high'],

                low=df['low'],

                close=df['close'])])

fig.update_layout(hovermode='x unified', autosize = True, title={

        'text': "High, low, open and close prices of BTCUSDT",

        'y':0.85,

        'x':0.5,

        'xanchor': 'center',

        'yanchor': 'top'})

fig.update_layout(hoverlabel=dict(

        bgcolor="white",

        font_size=22,

        font_family="Rockwell"))

fig.update_yaxes(type="log")

fig.show()

The problem is that after running it in Power BI Desktop Python script editor, it:

1)Does not show visual on PBI –shows error “can’t display visual”

Arvins_0-1685803304367.png

2)Internet browser starts trying to open URL page, showing “this site can’t be reached” and few times it even succeeds to open visualization (and shows as perfect as on Jupyter)!!!, which completely is not a purpose of this and script does not provide to do it!?

 

Could you please advise what would is a problem and is it necessary to do extra manipulations in PBI Desktop for Python script to be working properly?

p.s. I have all necessary Python modules installed and paths are correct in PBI Python scripting options – otherwise it would not be possible to load script into PBI Desktop.

 

Regards,

0 REPLIES 0

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.